Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc150871

Browse files
Update to JUnit5 across all modules (iluwatar#1668)
* Updated saga to JUnit 5* Update fix for CI job in trampoline module* Updated update-method module to JUnit 5* Upgraded to latest JUnit JupiterJUnit 4 is not needed when using JUnit-Vintage* Reverted change to access modifier on Trampoline* Cleanup to resolve code smells* Formatting* Formatting* Migrating to JUnit5 and updating some Mockito patterns* Migrating to JUnit5* Migrating to JUnit5* Migrating to JUnit 5* Formatting cleanup* Added missing scope for junit* Fixed tests that were not running previously.Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
1 parente9d0b3e commitc150871

File tree

53 files changed

+333
-412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+333
-412
lines changed

‎arrange-act-assert/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
<artifactId>arrange-act-assert</artifactId>
3737
<dependencies>
3838
<dependency>
39-
<groupId>junit</groupId>
40-
<artifactId>junit</artifactId>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter-engine</artifactId>
4141
<scope>test</scope>
4242
</dependency>
4343
</dependencies>

‎arrange-act-assert/src/test/java/com/iluwatar/arrangeactassert/CashAAATest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
packagecom.iluwatar.arrangeactassert;
2525

26-
importstaticorg.junit.Assert.assertEquals;
27-
importstaticorg.junit.Assert.assertFalse;
28-
importstaticorg.junit.Assert.assertTrue;
26+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
27+
importstaticorg.junit.jupiter.api.Assertions.assertFalse;
28+
importstaticorg.junit.jupiter.api.Assertions.assertTrue;
2929

30-
importorg.junit.Test;
30+
importorg.junit.jupiter.api.Test;
3131

3232
/**
3333
* Arrange/Act/Assert (AAA) is a pattern for organizing unit tests. It is a way to structure your
@@ -51,10 +51,11 @@
5151
* change and one reason to fail. In a large and complicated code base, tests that honor the single
5252
* responsibility principle are much easier to troubleshoot.
5353
*/
54-
publicclassCashAAATest {
54+
55+
classCashAAATest {
5556

5657
@Test
57-
publicvoidtestPlus() {
58+
voidtestPlus() {
5859
//Arrange
5960
varcash =newCash(3);
6061
//Act
@@ -64,7 +65,7 @@ public void testPlus() {
6465
}
6566

6667
@Test
67-
publicvoidtestMinus() {
68+
voidtestMinus() {
6869
//Arrange
6970
varcash =newCash(8);
7071
//Act
@@ -75,7 +76,7 @@ public void testMinus() {
7576
}
7677

7778
@Test
78-
publicvoidtestInsufficientMinus() {
79+
voidtestInsufficientMinus() {
7980
//Arrange
8081
varcash =newCash(1);
8182
//Act
@@ -86,7 +87,7 @@ public void testInsufficientMinus() {
8687
}
8788

8889
@Test
89-
publicvoidtestUpdate() {
90+
voidtestUpdate() {
9091
//Arrange
9192
varcash =newCash(5);
9293
//Act

‎arrange-act-assert/src/test/java/com/iluwatar/arrangeactassert/CashAntiAAATest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,24 @@
2323

2424
packagecom.iluwatar.arrangeactassert;
2525

26-
importstaticorg.junit.Assert.assertEquals;
27-
importstaticorg.junit.Assert.assertFalse;
28-
importstaticorg.junit.Assert.assertTrue;
26+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
27+
importstaticorg.junit.jupiter.api.Assertions.assertFalse;
28+
importstaticorg.junit.jupiter.api.Assertions.assertTrue;
2929

30-
importorg.junit.Test;
30+
importorg.junit.jupiter.api.Test;
3131

3232
/**
3333
* ({@link CashAAATest}) is an anti-example of AAA pattern. This test is functionally correct, but
34-
* with the addition of new feature, it needs refactoring. There are an awful lot of steps in that
34+
* with the addition ofanew feature, it needs refactoring. There are an awful lot of steps in that
3535
* test method, but it verifies the class' important behavior in just eleven lines. It violates the
3636
* single responsibility principle. If this test method failed after a small code change, it might
3737
* take some digging to discover why.
3838
*/
39-
publicclassCashAntiAAATest {
39+
40+
classCashAntiAAATest {
4041

4142
@Test
42-
publicvoidtestCash() {
43+
voidtestCash() {
4344
//initialize
4445
varcash =newCash(3);
4546
//test plus

‎async-method-invocation/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
<artifactId>mockito-core</artifactId>
4646
<scope>test</scope>
4747
</dependency>
48-
<dependency>
49-
<groupId>junit</groupId>
50-
<artifactId>junit</artifactId>
51-
<scope>test</scope>
52-
</dependency>
5348
</dependencies>
5449
<build>
5550
<plugins>

‎combinator/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434

3535
<artifactId>combinator</artifactId>
3636
<dependencies>
37-
<dependency>
38-
<groupId>junit</groupId>
39-
<artifactId>junit</artifactId>
40-
<scope>test</scope>
41-
</dependency>
42-
4337
<dependency>
4438
<groupId>org.junit.jupiter</groupId>
4539
<artifactId>junit-jupiter-engine</artifactId>

‎combinator/src/test/java/com/iluwatar/combinator/CombinatorAppTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
packagecom.iluwatar.combinator;
2525

26-
importorg.junit.Test;
27-
2826
importstaticorg.junit.jupiter.api.Assertions.assertDoesNotThrow;
2927

30-
publicclassCombinatorAppTest {
28+
importorg.junit.jupiter.api.Test;
29+
30+
classCombinatorAppTest {
3131

3232
/**
3333
* Issue: Add at least one assertion to this test case.
@@ -37,7 +37,7 @@ public class CombinatorAppTest {
3737
*/
3838

3939
@Test
40-
publicvoidshouldExecuteApplicationWithoutException() {
40+
voidshouldExecuteApplicationWithoutException() {
4141
assertDoesNotThrow(() ->CombinatorApp.main(newString[]{}));
4242
}
43-
}
43+
}

‎combinator/src/test/java/com/iluwatar/combinator/FinderTest.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,19 @@
2323

2424
packagecom.iluwatar.combinator;
2525

26-
importorg.junit.Assert;
27-
importorg.junit.Test;
26+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
2827

29-
importjava.util.List;
28+
importorg.junit.jupiter.api.Test;
3029

31-
importstaticorg.junit.Assert.*;
32-
33-
publicclassFinderTest {
30+
classFinderTest {
3431

3532
@Test
36-
publicvoidcontains() {
33+
voidcontains() {
3734
varexample ="the first one\nthe second one\n";
3835

3936
varresult =Finder.contains("second").find(example);
40-
Assert.assertEquals(result.size(),1);
41-
Assert.assertEquals(result.get(0),"the second one ");
37+
assertEquals(1,result.size());
38+
assertEquals("the second one ",result.get(0));
4239
}
4340

44-
}
41+
}

‎combinator/src/test/java/com/iluwatar/combinator/FindersTest.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,44 @@
2323

2424
packagecom.iluwatar.combinator;
2525

26-
importorg.junit.Assert;
27-
importorg.junit.Test;
26+
importstaticcom.iluwatar.combinator.Finders.advancedFinder;
27+
importstaticcom.iluwatar.combinator.Finders.expandedFinder;
28+
importstaticcom.iluwatar.combinator.Finders.filteredFinder;
29+
importstaticcom.iluwatar.combinator.Finders.specializedFinder;
30+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
2831

29-
importjava.util.List;
32+
importorg.junit.jupiter.api.Test;
3033

31-
importstaticcom.iluwatar.combinator.Finders.*;
32-
importstaticorg.junit.Assert.*;
33-
34-
publicclassFindersTest {
34+
classFindersTest {
3535

3636
@Test
37-
publicvoidadvancedFinderTest() {
37+
voidadvancedFinderTest() {
3838
varres =advancedFinder("it was","kingdom","sea").find(text());
39-
Assert.assertEquals(res.size(),1);
40-
Assert.assertEquals(res.get(0),"It was many and many a year ago,");
39+
assertEquals(1,res.size());
40+
assertEquals("It was many and many a year ago,",res.get(0));
4141
}
4242

4343
@Test
44-
publicvoidfilteredFinderTest() {
44+
voidfilteredFinderTest() {
4545
varres =filteredFinder(" was ","many","child").find(text());
46-
Assert.assertEquals(res.size(),1);
47-
Assert.assertEquals(res.get(0),"But we loved with a love that was more than love-");
46+
assertEquals(1,res.size());
47+
assertEquals("But we loved with a love that was more than love-",res.get(0));
4848
}
4949

5050
@Test
51-
publicvoidspecializedFinderTest() {
51+
voidspecializedFinderTest() {
5252
varres =specializedFinder("love","heaven").find(text());
53-
Assert.assertEquals(res.size(),1);
54-
Assert.assertEquals(res.get(0),"With a love that the winged seraphs of heaven");
53+
assertEquals(1,res.size());
54+
assertEquals("With a love that the winged seraphs of heaven",res.get(0));
5555
}
5656

5757
@Test
58-
publicvoidexpandedFinderTest() {
58+
voidexpandedFinderTest() {
5959
varres =expandedFinder("It was","kingdom").find(text());
60-
Assert.assertEquals(res.size(),3);
61-
Assert.assertEquals(res.get(0),"It was many and many a year ago,");
62-
Assert.assertEquals(res.get(1),"In a kingdom by the sea,");
63-
Assert.assertEquals(res.get(2),"In this kingdom by the sea;");
60+
assertEquals(3,res.size());
61+
assertEquals("It was many and many a year ago,",res.get(0));
62+
assertEquals("In a kingdom by the sea,",res.get(1));
63+
assertEquals("In this kingdom by the sea;",res.get(2));
6464
}
6565

6666

@@ -80,4 +80,4 @@ private String text(){
8080
+"Coveted her and me.";
8181
}
8282

83-
}
83+
}

‎double-buffer/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
<artifactId>double-buffer</artifactId>
3737

3838
<dependencies>
39-
<dependency>
40-
<groupId>junit</groupId>
41-
<artifactId>junit</artifactId>
42-
</dependency>
4339
<dependency>
4440
<groupId>org.apache.commons</groupId>
4541
<artifactId>commons-lang3</artifactId>

‎double-buffer/src/test/java/com/iluwatar/doublebuffer/AppTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323

2424
packagecom.iluwatar.doublebuffer;
2525

26-
importorg.junit.Test;
27-
2826
importstaticorg.junit.jupiter.api.Assertions.assertDoesNotThrow;
2927

28+
importorg.junit.jupiter.api.Test;
29+
3030
/**
3131
* App unit test.
3232
*/
33-
publicclassAppTest {
33+
classAppTest {
3434

3535
/**
3636
* Issue: Add at least one assertion to this test case.
@@ -40,7 +40,7 @@ public class AppTest {
4040
*/
4141

4242
@Test
43-
publicvoidshouldExecuteApplicationWithoutException() {
43+
voidshouldExecuteApplicationWithoutException() {
4444
assertDoesNotThrow(() ->App.main(newString[]{}));
4545
}
4646

‎double-buffer/src/test/java/com/iluwatar/doublebuffer/FrameBufferTest.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@
2323

2424
packagecom.iluwatar.doublebuffer;
2525

26+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
27+
importstaticorg.junit.jupiter.api.Assertions.fail;
28+
2629
importjava.util.Arrays;
27-
importorg.junit.Assert;
28-
importorg.junit.Test;
30+
importorg.junit.jupiter.api.Test;
2931

3032
/**
3133
* FrameBuffer unit test.
3234
*/
33-
publicclassFrameBufferTest {
35+
classFrameBufferTest {
3436

3537
@Test
36-
publicvoidtestClearAll() {
38+
voidtestClearAll() {
3739
try {
3840
varfield =FrameBuffer.class.getDeclaredField("pixels");
3941
varpixels =newPixel[FrameBuffer.HEIGHT *FrameBuffer.WIDTH];
@@ -43,14 +45,14 @@ public void testClearAll() {
4345
field.setAccessible(true);
4446
field.set(frameBuffer,pixels);
4547
frameBuffer.clearAll();
46-
Assert.assertEquals(Pixel.WHITE,frameBuffer.getPixels()[0]);
48+
assertEquals(Pixel.WHITE,frameBuffer.getPixels()[0]);
4749
}catch (NoSuchFieldException |IllegalAccessExceptione) {
48-
Assert.fail("Fail to modify field access.");
50+
fail("Fail to modify field access.");
4951
}
5052
}
5153

5254
@Test
53-
publicvoidtestClear() {
55+
voidtestClear() {
5456
try {
5557
varfield =FrameBuffer.class.getDeclaredField("pixels");
5658
varpixels =newPixel[FrameBuffer.HEIGHT *FrameBuffer.WIDTH];
@@ -60,21 +62,21 @@ public void testClear() {
6062
field.setAccessible(true);
6163
field.set(frameBuffer,pixels);
6264
frameBuffer.clear(0,0);
63-
Assert.assertEquals(Pixel.WHITE,frameBuffer.getPixels()[0]);
65+
assertEquals(Pixel.WHITE,frameBuffer.getPixels()[0]);
6466
}catch (NoSuchFieldException |IllegalAccessExceptione) {
65-
Assert.fail("Fail to modify field access.");
67+
fail("Fail to modify field access.");
6668
}
6769
}
6870

6971
@Test
70-
publicvoidtestDraw() {
72+
voidtestDraw() {
7173
varframeBuffer =newFrameBuffer();
7274
frameBuffer.draw(0,0);
73-
Assert.assertEquals(Pixel.BLACK,frameBuffer.getPixels()[0]);
75+
assertEquals(Pixel.BLACK,frameBuffer.getPixels()[0]);
7476
}
7577

7678
@Test
77-
publicvoidtestGetPixels() {
79+
voidtestGetPixels() {
7880
try {
7981
varfield =FrameBuffer.class.getDeclaredField("pixels");
8082
varpixels =newPixel[FrameBuffer.HEIGHT *FrameBuffer.WIDTH];
@@ -83,9 +85,9 @@ public void testGetPixels() {
8385
varframeBuffer =newFrameBuffer();
8486
field.setAccessible(true);
8587
field.set(frameBuffer,pixels);
86-
Assert.assertEquals(pixels,frameBuffer.getPixels());
88+
assertEquals(pixels,frameBuffer.getPixels());
8789
}catch (NoSuchFieldException |IllegalAccessExceptione) {
88-
Assert.fail("Fail to modify field access.");
90+
fail("Fail to modify field access.");
8991
}
9092
}
9193

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp