Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
course-material
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IT1901
course-material
Commits
9dc7dd22
Commit
9dc7dd22
authored
4 years ago
by
Hallvard Trætteberg
Browse files
Options
Downloads
Patches
Plain Diff
parameterisert test
parent
3665d552
No related branches found
No related tags found
No related merge requests found
Pipeline
#90514
passed
4 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
antipatterns/pom.xml
+9
-3
9 additions, 3 deletions
antipatterns/pom.xml
antipatterns/src/test/java/antipatterns/DataClassWithValidationTest.java
+17
-0
17 additions, 0 deletions
...c/test/java/antipatterns/DataClassWithValidationTest.java
with
26 additions
and
3 deletions
antipatterns/pom.xml
+
9
−
3
View file @
9dc7dd22
...
...
@@ -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>
...
...
This diff is collapsed.
Click to expand it.
antipatterns/src/test/java/antipatterns/DataClassWithValidationTest.java
+
17
−
0
View file @
9dc7dd22
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
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment