SKILL BENCHMARK
Java Unit Testing Competency (Intermediate Level)
- 15m
- 15 questions
The Java Unit Testing Competency benchmark evaluates your skills to write and run JUnit tests and identify the right situation to construct and use mock objects. You will be assessed on your ability to use assertions and annotations in JUnit and execute tests in Apache Maven and JUnit ConsoleLauncher. A learner who scores high on this benchmark demonstrates that they have the skills to write and run JUnit tests and also perform unit testing with mocks.
Topics covered
- build tests to verify that method calls throw an exception when invalid data is passed to it
- compile and run enabled test cases in your project using Apache Maven
- compile and run enabled test cases in your project using the JUnit ConsoleLauncher
- configure a test case to execute only when a specified assumption is satisfied
- configure mocks with the when().thenReturn() syntax with input arguments
- create a customized JUnit annotation composed of several built-in annotations
- define a common set up and tear down method for all tests in a JUnit class
- demonstrate how ordered mocks work
- describe the libraries and annotations that can be used to define JUnit tests
- illustrate how the @InjectMock annotation works
- set parameterized tests to run for null and empty parameter values as well as CSV values
- throw exceptions from stubbed methods
- use spies with interfaces
- use the static mock() method to mock objects
- verify the invocations of a method