leo-y
5/6/2018 - 12:24 AM

Junit

junit

gradle test
 Measure code coverage by executing ‘gradle cobertura’ and investigating the report in build/reports/cobertura/index.html; alternatively run your IDE’s code coverage tool.


1. @Test: marks a public method without parameters as a test case

2. @Before: marks a method as a setup method, to be called before every test case.

3. @After: marks method as a teardown method, to be called after every test case.

4. @Ignore: marks a test case as ignored; such test cases are reported but not executed.

5. @Test(expected = NullPointerException): marks a test case that expects the exception specified after expected =. If the expected type of exception arises, the test case passes.


1. assertEquals(expected, actual ): requires the value expected to be equal to actual

2. assertArrayEquals(expected, actual ): requires the array expected to be equal to actual.

3. assertTrue(cond ): requires cond to have value true

4. assertNotNull(obj ): requires obj to be non-null