"Charting the Course ...

... to Your Success!"

Java Test Driven Development with TestNG

Course Summary

Description

Test Driven Development (TDD) has become a standard best practice for developers, especially those working in an Agile development environment. TDD is more than just automated , it is a team and individual development discipline that, when followed correctly, increases productivity of both individual developers and entire teams. From the programmer’s perspective, TDD has another benefit – it allows programmers to eliminate the tedious tasks of debugging and reworking code so that programmers can focus on the creative work of designing and writing code. It makes programming fun again.

The course integrates two primary learning streams.

The first is the how to effectively implement TDD in a production or development environment and integrating TDD practices with other practices like software craftsmanship, agile design practices, continuous integration and best practices in object oriented programming and Java development.

The second learning stream is an in depth and hands on deep dive into Java TDD tools such as mocking libraries, matching libraries and the TestNG framework itself. TestNG (Test Next Generation) is a test framework inspired by JUnit and NUnit but with additional features and functionality The class is designed to be about 50% hands on labs and exercises, about 25% theory and 25% instructor led hands on learning where students code along with the instructor.

Topics

 The TDD process - “red, green, refactor”  Assertion libraries (hamcrest, etc.)  Eliminating technical debt with TDD  Using Mocks effectively  Why TDD works  Mocking libraries (Mockito, JMockit,  Integrating the TDD discipline into a EasyMock, etc.) development process  How to developing good tests and test suites  Using TDD to support programming and  Best practices when using TDD and JUnit to design best practices improve development  Developing a TDD project using TestNG  Code smells and refactoring  TestNG concepts, architecture and features  Using TDD to refactor code  Organizing and managing tests using  Migrating to TDD as a programming testng.xml discipline

Audience

This course is designed for Java programmers.

Prerequisites

Before taking this course, students should have a good knowledge of Java and have at least an intermediate programming skill level.

Duration

Three days

Due to the nature of this material, this document refers to numerous hardware and software products by their trade names. References to other companies and their products are for informational purposes only, and all trademarks are the properties of their respective companies. It is not the intent of ProTech Professional Technical Services, Inc. to use any of these names generically

"Charting the Course ...

... to Your Success!"

Java Test Driven Development with TestNG

Course Outline

I. Java Test Driven Development IV. More JUnit Introduction A. Design by contract A. The TDD process as a discipline B. Writing tests for preconditions, post- B. How TDD improves efficiency and conditions and invariants effectiveness of programming C. Testing exceptions with TestNG C. Eliminating technical debt, debugging D. Using testNH test fixtures effectively and rework E. Selective execution of tests and D. Integrating TDD with best practices in grouping of tests program design and coding F. Ordering the addition of of tests into E. TDD as a a core Agile practice TestNG F. The Agile testing quadrants G. Differences between test errors and G. The importance of test automation test failures H. Refactoring: what it is and why we do it V. Testing Concepts A. Criteria for good testing: validity, II. An Introduction to TestNG accuracy and reliability A. TestNG architecture and functionality B. Why our tests have to be correct B. The TDD process implemented with C. Common sources of test case errors TestNG D. Systematic and algorithmic test case C. Runners, fixtures and test execution development D. Using the testing.xml file to run tests E. Deriving test cases from acceptance E. TestNG assertions – how tests pass tests and fail F. Functional coverage measures F. TestNG annotations G. Determining optimal numbers of tests G. Writing and validating a TestNG test H. Using test cases to identify H. Introduction to matchers and mocks requirements and specification problems III. TDD Best Practices I I. Dealing with valid, invalid and outlier A. Testing through interfaces test cases B. Command / Query segregation J. Combinatorial versus stateful testing C. Functional testing concepts D. Relationship between good class VI. Assertions and Predicates design and ease of testing A. Four generations of assertions: Java, E. Understanding Unit testing – JUnit, Hamcrest and AssertJ component isolation B. Using hamcrest to develop complex F. Planning the development to minimize assertion predicates work C. Using hamcrest to examine structures, G. How to decide what test to add next lists, etc H. Errors, faults, failures and exceptions D. Writing complex predicates in AssertJ I. TDD best practices E. Overview of hamcrest and AssertJ J. Common errors when implementing features TDD

Due to the nature of this material, this document refers to numerous hardware and software products by their trade names. References to other companies and their products are for informational purposes only, and all trademarks are the properties of their respective companies. It is not the intent of ProTech Professional Technical Services, Inc. to use any of these names generically

"Charting the Course ...

... to Your Success!"

Java Test Driven Development with TestNG

Course Outline (cont’d)

VII. Mocking and Mock Libraries IX. Refactoring A. Mocks, stubs, drivers and component A. Refactoring as controlled code unit testing changes B. Implementing interfaces with a mock B. Using TDD to implement a refactoring object C. Code smells – driver for refactoring C. Overview of mocking libraries: D. Code refactoring versus design EasyMock, Mockido, JMockit ec. refactoring D. How mocking libraries work E. Refactoring to a design pattern E. Implementing and using mocks from a F. Using refactoring to reduce technical mocking library debt F. Designing and implementing a G. Refactoring best practices mocking strategy X. Implementing TDD VIII. TDD Best Practices II A. Review of TDD best practices A. Organizing and maintaining the test B. Review of JUnit best practices environment C. Planning a TDD project B. Testing the test code D. Integrating TDD into a development C. Developing tests and code design process together E. Integrating TDD with coding D. Deciding intensive and excellence comprehensive should be F. The importance of metrics E. TDD implementation patterns G. Developing an implementation plan F. Metrics for TDD H. Pitfalls, snares and traps to avoid

Due to the nature of this material, this document refers to numerous hardware and software products by their trade names. References to other companies and their products are for informational purposes only, and all trademarks are the properties of their respective companies. It is not the intent of ProTech Professional Technical Services, Inc. to use any of these names generically