Merge pull request #5450 from amit2103/BAEL-9635
[BAEL-9635] - Moved Junit vs TestNg junit code examples to junit-5 mo…
This commit is contained in:
commit
e51b8261c7
6
pom.xml
6
pom.xml
|
@ -46,6 +46,12 @@
|
|||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package com.baeldung.junit5vstestng;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class SummationServiceIntegrationTest {
|
||||
private static List<Integer> numbers;
|
||||
|
||||
@BeforeAll
|
||||
public static void initialize() {
|
||||
numbers = new ArrayList<>();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
numbers = null;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void runBeforeEachTest() {
|
||||
numbers.add(1);
|
||||
numbers.add(2);
|
||||
numbers.add(3);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void runAfterEachTest() {
|
||||
numbers.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenNumbers_sumEquals_thenCorrect() {
|
||||
int sum = numbers.stream()
|
||||
.reduce(0, Integer::sum);
|
||||
Assert.assertEquals(6, sum);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void givenEmptyList_sumEqualsZero_thenCorrect() {
|
||||
int sum = numbers.stream()
|
||||
.reduce(0, Integer::sum);
|
||||
Assert.assertEquals(6, sum);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package org.baeldung.java.parameterisedsource;
|
||||
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -13,8 +12,6 @@ import org.junit.jupiter.params.provider.EnumSource;
|
|||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import com.baeldung.enums.PizzaDeliveryStrategy;
|
||||
|
||||
public class ParameterizedUnitTest {
|
||||
|
||||
@ParameterizedTest
|
|
@ -0,0 +1,6 @@
|
|||
package org.baeldung.java.parameterisedsource;
|
||||
|
||||
public enum PizzaDeliveryStrategy {
|
||||
EXPRESS,
|
||||
NORMAL;
|
||||
}
|
Loading…
Reference in New Issue