Commit 9dc7dd22 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

parameterisert test

parent 3665d552
Pipeline #90514 passed with stage
in 1 minute and 24 seconds
......@@ -10,15 +10,21 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.4.2</version>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
......
package antipatterns;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
public class DataClassWithValidationTest {
private DataClassWithValidation instance1;
@BeforeEach
public void setup() {
instance1 = new DataClassWithValidation();
}
@Test
public void testConstructor() {
try {
......@@ -32,4 +42,11 @@ public class DataClassWithValidationTest {
public void testBetterConstructor_validName() {
new DataClassWithValidation("ok name");
}
@ParameterizedTest
@ValueSource(strings = {" starts with blank"})
public void testBetterSetName_invalidName(String name) {
Assertions.assertThrows(IllegalArgumentException.class, () -> instance1.setName(name));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment