Skip to content

Instantly share code, notes, and snippets.

View weikangchia's full-sized avatar

Wei Kang weikangchia

View GitHub Profile
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
import org.junit.Test;
public class JUnit4Test {
@Test(expected = RuntimeException.class)
public void shouldThrowRuntimeException() {
throw new RuntimeException("Exception met");
}
@Test(timeout = 1)
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
<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>
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"separateMinorPatch": true,
"stabilityDays": 3,
"labels": ["dependency-upgrade"],
"prHourlyLimit": 0
}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: krakend-cm
labels:
name: krakend-cm
data:
krakend.json: |
{
---
apiVersion: v1
kind: Service
metadata:
name: krakend-svc
labels:
name: krakend-svc
spec:
type: ClusterIP
selector:
---
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
@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);
}