JUnit 4 | JUnit 5 | Description |
---|---|---|
@BeforeClass | @BeforeAll | Denotes that the annotated method should be executed before all @Tests , @RepeatedTest , @ParameterizedTest , and @TestFactory methods in the current class. |
@AfterClass | @AfterAll | Denotes that the annotated method should be executed after all @Tests , @RepeatedTest , @ParameterizedTest , and @TestFactory methods in the current class. |
@Before | @BeforeEach | Denotes that the annotated method should be executed before each @Test , @RepeatedTest , @ParameterizedTest , or @TestFactory method in the current class. |
@After | @AfterEach | Denotes that the annotated method should be executed after each @Test , @RepeatedTest , @ParameterizedTest , or @TestFactory method in the current class. |
@Ignore | @Disable | Denotes that the test class or test method is disabled |
@Categeory | @Tag | Used to declare tags for filtering tests, either at the class or method level |
@Test | @Test | Denotes that a method is a test method |
- | @Parameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.jupiter.api.Test; | |
import java.time.Duration; | |
import static org.junit.jupiter.api.Assertions.assertThrows; | |
import static org.junit.jupiter.api.Assertions.assertTimeout; | |
class JUnit5Test { | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test; | |
public class JUnit4Test { | |
@Test(expected = RuntimeException.class) | |
public void shouldThrowRuntimeException() { | |
throw new RuntimeException("Exception met"); | |
} | |
@Test(timeout = 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>org.junit.jupiter</groupId> | |
<artifactId>junit-jupiter</artifactId> | |
<version>5.8.2</version> | |
<scope>test</scope> | |
</dependency> | |
<!-- If you need to still run JUnit 4 tests --> | |
<dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | |
"extends": [ | |
"config:base" | |
], | |
"separateMinorPatch": true, | |
"stabilityDays": 3, | |
"labels": ["dependency-upgrade"], | |
"prHourlyLimit": 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: krakend-cm | |
labels: | |
name: krakend-cm | |
data: | |
krakend.json: | | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: krakend-svc | |
labels: | |
name: krakend-svc | |
spec: | |
type: ClusterIP | |
selector: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: krakend-deployment | |
labels: | |
name: krakend-deployment | |
app: krakend | |
tier: app | |
spec: |
# Homebrew
brew install colima
# Nix
nix-env -iA nixpkgs.colima
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ParameterizedTest | |
@CsvSource(value = {"M,21", "M, 31"}) | |
void Given_MaleGenderWithAgeGreaterThan20_When_Test_Then_ShouldReturnTrue(Gender genderEnumToTest, int ageToTest) { | |
assertEquals(Gender.M, genderEnumToTest); | |
assertThat(ageToTest).isGreaterThan(20); | |
} |
NewerOlder