Skip to content
Snippets Groups Projects
Commit 9dc7dd22 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

parameterisert test

parent 3665d552
No related branches found
No related tags found
No related merge requests found
Pipeline #90514 passed
......@@ -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));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment