@ -79,7 +79,7 @@ uni.onItem()
* Microprofile + SmallRye
* JUnit
* TestNG
* TestNG - Many of its features on the roadmap for JUnit 5.x anyway
* Jenkins, CI, piplines Blue Ocean
* Maven - Already know most of this
* Have fixed bugs in maven plugins
@ -94,7 +94,75 @@ uni.onItem()
* Vintage - API for older JUnit4 tests
* Ext - 3rd Party extensions (custom API aka SPI)
"No news is good news" - We only care for failures
* `@Test` annotation to highlight test method we'd like to run as part of JUnit tests
* Common assert methods
```java
assertEquals(expected, actual, "Description of failure") // Asserts both values are equal
assertArrayEquals(expectedArray, actualArray) //Verifies each item in the array are equal in the right position/order
assertIterableEquals(expectedArray, actualArray) // Verifies iterables, again equal and in the right position/order
fail() //Always fail... duh
assertAll(
() -> assertEquals(expected, actual),
//() -> ...
)
```
Surefire plugin in maven to run JUnit tests (thing we always disabled in Prod :wink:)
* Test lifecycle annotations
```java
@BeforeAll //needs to be static method
@AfterAll //needs to be a static method
@BeforeEach
@AfterEach
//eg init a new pojo for each test
class Foo {
SomePojo pojo;
@BeforeEach
void init() {
pojo = new SomePojo();
}
}
```
* Nested
```java
class Foo {
@Nested
class Bar {
@Test
@DisplayName ("Test Description")
void dosomething()
{
assertEquals(expected, pojo.method(x,y), "Test description");
assertEquals(Somethinexpected, pojo.method(x), "Test description 2"
}
void dosomethingelse()
{
assertEquals(expected, pojo.method(x,y), "Test description");
assertEquals(Somethinexpected, pojo.method(x), "Test description 2"
}
}
}
```
* Lambda for lazy tests
```java
assertEquals(expected, actual, () -> "big bad string: " + expected + "actual: " + actual) //Will only execute lambda if assert fires
```
* Repeated test `@RepeatedTest(n)` - Repeat a test multiple times (n number of times) has [RepetitionInfo ](https://junit.org/junit5/docs/5.0.0/api/org/junit/jupiter/api/RepetitionInfo.html )
* `@Tag` annotation allows running of many or few of multiple tags
* JUnit provides many providers (injected) eg. `RepetitionInfo` or `testInfo`
### QE tests