Max Pronko | Pronko Consulting | 10 Pitfalls with Test Driven Development for Magento teams

Meet Magento UK
1 Jul 202423:20

Summary

TLDRMax Bronco presents a talk on Test-Driven Development (TDD), explaining its process and benefits. He guides through implementing TDD in teams, using PHP unit library, and emphasizes the importance of writing tests before code. Max also discusses pitfalls and shares resources for further learning.

Takeaways

  • 😀 Max Bronco has over 15 years of experience in developing cutting-edge solutions with Adobe Commerce and Magento, serving Fortune 500 companies.
  • 🏆 Max was recognized as a top Magento contributor for four consecutive years and a Magento Master in 2020.
  • 📚 The presentation aims to introduce Test-Driven Development (TDD) and encourage its implementation in teams, as well as offering a chance to win a free online course.
  • 🔍 TDD is defined as writing a unit test before writing any code, with the mantra 'Red, Green, Refactor', emphasizing the importance of tests in guiding development.
  • 🛠️ Essential tools for TDD in Magento teams include the PHP unit library and a proper XML configuration file, which can be installed via Composer.
  • 📝 The script provides a step-by-step example of how to follow TDD, from writing a failing test to implementing just enough code to pass the test, and then refactoring.
  • 🔧 Refactoring is a critical part of TDD, allowing developers to improve the code structure without changing its external behavior, ensuring tests still pass.
  • 🔄 The script discusses the importance of using interfaces and mocks in TDD to avoid dependencies on external systems and to simplify testing.
  • 📈 TDD can lead to 100% test coverage, which is beneficial for ensuring that all parts of the code are tested and can be safely refactored.
  • 🚧 The presenter differentiates between unit tests, integration tests, web API tests, and functional tests, highlighting that TDD is most applicable to unit and integration tests due to their speed and feedback.
  • 🚀 Benefits of TDD include time savings in the long run, reduced bugs, and improved documentation within the source code.

Q & A

  • Who is the presenter of the talk, and what is their area of expertise?

    -The presenter is Max Bronco, who has over 15 years of experience leading the development of cutting-edge solutions with Adab Commerce and Magento, catering to Fortune 500 companies.

  • What is Max Bronco's contribution to the Magento community?

    -Max Bronco was named a top Magento contributor for four consecutive years and a Magento Master in 2020, excelling in mastering intricate Magento challenges.

  • What is the main focus of Max Bronco's presentation?

    -The main focus of the presentation is to introduce and encourage the implementation of Test-Driven Development (TDD) in teams, particularly within the Magento community.

  • What is the 'red-green-refactor' mantra associated with TDD?

    -The 'red-green-refactor' mantra is a key principle of TDD which involves writing a test that initially fails (red), then writing just enough code to pass the test (green), and finally refactoring the code to meet acceptance criteria.

  • What is the basic requirement for implementing TDD in a Magento project?

    -The basic requirement for implementing TDD in a Magento project is having a PHP unit library or any other xUnit library. It's also recommended to have a PHP unit XML configuration file.

  • How can a Magento 2 project be set up to use PHP unit for TDD?

    -To set up a Magento 2 project for TDD, one needs to run 'composer require phpunit/phpunit --dev' to install PHP unit, generate a PHP unit XML configuration file, and create a directory for unit tests.

  • What is the purpose of the 'test is active' method in the popup service class example?

    -The 'test is active' method in the popup service class example is used to demonstrate the TDD process, starting with writing a test that checks if the 'isActive' method returns the expected boolean value.

  • What is the significance of refactoring in the TDD process?

    -Refactoring is significant in TDD as it allows developers to improve the structure of existing code without changing its external behavior, ensuring that the code remains clean and maintainable even as new features are added.

  • Why is it recommended to avoid using the Object Manager in unit tests when following TDD?

    -Using the Object Manager in unit tests can lead to tests that are not truly unit tests but rather integration tests, as they depend on the Magento framework's services. This can make tests slower and less focused, which goes against the principles of TDD.

  • What are some pitfalls of Test-Driven Development mentioned in the script?

    -Some pitfalls include skipping the red-green-refactor cycle, having slow tests, using Object Manager in unit tests, lack of mocking and stubbing, and not adhering to the Law of Demeter.

  • What are the benefits of practicing Test-Driven Development mentioned in the presentation?

    -The benefits of TDD include saving time in the long run, reducing bugs, providing documentation in the source code, and allowing for more confident refactoring.

  • What resources does Max Bronco recommend for further learning about Test-Driven Development?

    -Max Bronco recommends books, presentations, videos, and documentations related to TDD, which can be accessed by scanning a provided barcode with a smartphone.

Outlines

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф

Mindmap

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф

Keywords

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф

Highlights

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф

Transcripts

plate

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.

Перейти на платный тариф
Rate This

5.0 / 5 (0 votes)

Связанные теги
Test-Driven DevelopmentMagentoCoding PracticesMax BroncoWeb DevelopmentOnline CourseUnit TestingRefactoringPHP UnitTDD Cycle
Вам нужно краткое изложение на английском?