File tree Expand file tree Collapse file tree 4 files changed +61
-20
lines changed
Expand file tree Collapse file tree 4 files changed +61
-20
lines changed Original file line number Diff line number Diff line change 1- TDDBC for Java with JUnit
2- ====================================
1+ # TDDBC for Java with JUnit5
32
43これは、TDDBCのJava向けJUnitプロジェクトです。
54
@@ -53,7 +52,7 @@ $ gradle eclipse
5352### テストの実行
5453
5554``` bash
56- $ gradle test
55+ $ gradle -q junit5Test
5756```
5857
5958### gradleによるJava Projectの作成(gradle 1.9以降)
@@ -88,7 +87,7 @@ mvn eclipse:eclipse
8887
8988### テストの実行
9089``` bash
91- mvn test
90+ mvn -Dtest= * test
9291```
9392
9493## その他
Original file line number Diff line number Diff line change 11apply plugin : ' java'
2+ apply plugin : ' org.junit.gen5.gradle'
23
34/* ide */
45apply {
@@ -12,17 +13,29 @@ project.ext {
1213}
1314version = ' 1.0-SNAPSHOT'
1415
15- sourceCompatibility = targetCompatibility = 1.7
16+ sourceCompatibility = targetCompatibility = 1.8
1617
1718tasks. withType(AbstractCompile ) each { it. options. encoding = ' UTF-8' }
1819
20+ buildscript {
21+ repositories {
22+ maven { url ' https://oss.sonatype.org/content/repositories/snapshots' }
23+ }
24+ dependencies {
25+ classpath ' org.junit:junit-gradle:5.0.0-SNAPSHOT'
26+ }
27+ }
28+
1929repositories {
2030 mavenCentral()
2131}
2232
2333dependencies {
24- testCompile ' junit:junit:4.11' , { exclude module : ' hamcrest-core' }
25- testCompile ' org.hamcrest:hamcrest-all:1.3'
34+ testCompile ' org.junit:junit5-api:5.0.0-ALPHA'
35+ }
36+
37+ junit5 {
38+ version ' 5.0.0-ALPHA'
2639}
2740
2841wrapper {
Original file line number Diff line number Diff line change 1212
1313 <properties >
1414 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
15+ <java .version>1.8</java .version>
1516 </properties >
1617
18+ <pluginRepositories >
19+ <pluginRepository >
20+ <id >snapshots-repo</id >
21+ <url >https://oss.sonatype.org/content/repositories/snapshots</url >
22+ <releases >
23+ <enabled >false</enabled >
24+ </releases >
25+ <snapshots >
26+ <updatePolicy >always</updatePolicy >
27+ <enabled >true</enabled >
28+ </snapshots >
29+ </pluginRepository >
30+ </pluginRepositories >
31+
1732 <dependencies >
1833 <dependency >
19- <groupId >junit</groupId >
20- <artifactId >junit</artifactId >
21- <version >4.11</version >
22- <scope >test</scope >
23- </dependency >
24- <dependency >
25- <groupId >org.hamcrest</groupId >
26- <artifactId >hamcrest-all</artifactId >
27- <version >1.3</version >
34+ <groupId >org.junit</groupId >
35+ <artifactId >junit5-api</artifactId >
36+ <version >5.0.0-ALPHA</version >
2837 <scope >test</scope >
2938 </dependency >
3039 </dependencies >
3140 <build >
3241 <plugins >
42+ <plugin >
43+ <artifactId >maven-compiler-plugin</artifactId >
44+ <version >3.1</version >
45+ <configuration >
46+ <source >${java.version} </source >
47+ <target >${java.version} </target >
48+ </configuration >
49+ </plugin >
3350 <plugin >
3451 <groupId >org.apache.maven.plugins</groupId >
3552 <artifactId >maven-eclipse-plugin</artifactId >
3653 <configuration >
3754 <downloadSources >true</downloadSources >
3855 </configuration >
3956 </plugin >
57+ <plugin >
58+ <artifactId >maven-surefire-plugin</artifactId >
59+ <version >2.19</version >
60+ <dependencies >
61+ <dependency >
62+ <groupId >org.junit</groupId >
63+ <artifactId >surefire-junit5</artifactId >
64+ <version >5.0.0-SNAPSHOT</version >
65+ </dependency >
66+ </dependencies >
67+ </plugin >
4068 </plugins >
4169 </build >
4270</project >
Original file line number Diff line number Diff line change 11package tddbc ;
22
3- import org .junit .Test ;
3+ import org .junit .gen5 .api .Test ;
4+ import org .junit .gen5 .api .DisplayName ;
5+ import static org .junit .gen5 .api .Assertions .*;
46
5- import static org .hamcrest .CoreMatchers .is ;
6- import static org .junit .Assert .assertThat ;
77
88public class SampleTest {
99
1010 @ Test
11+ @ DisplayName ("should return Hello TDD Boot Camp" )
1112 public void _should_return_Hello_TDD_BootCamp () throws Exception {
1213 // Setup
1314 Sample sut = new Sample ();
1415 // Exercise
1516 String actual = sut .say ();
1617 // Verify
17- assertThat ( actual , is ( "Hello TDD BootCamp!" ) );
18+ assertEquals ( "Hello TDD BootCamp!" , actual );
1819 }
1920
2021}
You can’t perform that action at this time.
0 commit comments