Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleTest.java
@Test
void testOnlyOnCertainMachines() {
   assumeTrue("dev".equals(System.getenv("ENV")),
   () -> "Aborting test as not needed on this computer");
   // rest of the test to run
}


ParameterizedTests
These allow you to run a test case multiple times with different arguments. These arguments can be strings, literal values, methods, Enums, CSV files, etc. @ParameterisedTest ultimately lets you avoid using unnecessary testing loops or duplicating test code.

Code Block
languagejava
titleTest.java
@ParameterizedTest
@ValueSource(ints = { 1, 2, 3 })
void testWithValueSource(int argument) {
   assertTrue(argument > 0 && argument < 4);
}

...