moving to Junit 5

This commit is contained in:
Bruce Eckel 2016-08-23 12:33:38 -06:00
parent e89d177b08
commit 2161792f99
6 changed files with 22 additions and 19 deletions

View File

@ -125,10 +125,12 @@ class Tags {
} }
} }
ext.junit4Version = '4.12' ext {
ext.junitVintageVersion = '4.12.0-M2' junit4Version = '4.12'
ext.junitPlatformVersion = '1.0.0-M2' junitVintageVersion = '4.12.0-M2'
ext.junitJupiterVersion = '5.0.0-M2' junitPlatformVersion = '1.0.0-M2'
junitJupiterVersion = '5.0.0-M2'
}
subprojects { subprojects {
apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.johnrengelman.shadow'
@ -146,7 +148,7 @@ subprojects {
} }
dependencies { dependencies {
//compile 'junit:junit:4.12' // compile 'junit:junit:4.12'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+' compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+' compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+'
// You can also use the JDK's built-in logging as the back end: // You can also use the JDK's built-in logging as the back end:
@ -159,11 +161,12 @@ subprojects {
// If you also want to support JUnit 3 and JUnit 4 tests // If you also want to support JUnit 3 and JUnit 4 tests
testCompile("junit:junit:${junit4Version}") testCompile("junit:junit:${junit4Version}")
testRuntime("org.junit.vintage:junit-vintage-engine:${junitVintageVersion}")*/ testRuntime("org.junit.vintage:junit-vintage-engine:${junitVintageVersion}")*/
compile "org.junit.jupiter:junit-jupiter-api:5.0.0-M2"
testCompile "org.junit.jupiter:junit-jupiter-api:5.0.0-M2" testCompile "org.junit.jupiter:junit-jupiter-api:5.0.0-M2"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.0.0-M2" testRuntime "org.junit.jupiter:junit-jupiter-engine:5.0.0-M2"
testCompile "junit:junit:4.12" /* testCompile "junit:junit:4.12"
testRuntime "org.junit.vintage:junit-vintage-engine:4.12.0-M2" testRuntime "org.junit.vintage:junit-vintage-engine:4.12.0-M2"
/* compile "org.junit.jupiter:junit-jupiter-api:5.0.0-M2" *//* compile "org.junit.jupiter:junit-jupiter-api:5.0.0-M2"
compile "org.junit.vintage:junit-vintage-engine:4.12.0-M2"*/ compile "org.junit.vintage:junit-vintage-engine:4.12.0-M2"*/
} }

View File

@ -4,8 +4,8 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Cloning a composed object // Cloning a composed object
// (Install libraries from junit.org) // (Install libraries from junit.org)
import org.junit.Test; import org.junit.jupiter.api.*;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
class DepthReading implements Cloneable { class DepthReading implements Cloneable {
private double depth; private double depth;

View File

@ -3,8 +3,8 @@
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package verifying; package verifying;
import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.*;
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*;
class FirstJUnit5Tests { class FirstJUnit5Tests {
@Test @Test

View File

@ -4,8 +4,8 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
package verifying; package verifying;
import verifying.Queue; import verifying.Queue;
import org.junit.Test; import org.junit.jupiter.api.*;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
public class QueueTest { public class QueueTest {
private Queue queue = new Queue(10); private Queue queue = new Queue(10);

View File

@ -5,8 +5,8 @@
// Simple use of JUnit to test ArrayList // Simple use of JUnit to test ArrayList
package verifying; package verifying;
import java.util.*; import java.util.*;
import org.junit.*; import org.junit.jupiter.api.*;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
// Keeps track of list objects as they are // Keeps track of list objects as they are
// created and cleaned up: // created and cleaned up:

View File

@ -4,10 +4,10 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ValidateByHand} // Don't run by itself // {ValidateByHand} // Don't run by itself
import java.util.*; import java.util.*;
import org.junit.*; import org.junit.jupiter.api.*;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import org.junit.runner.*; import org.junit.jupiter.runner.*;
import org.junit.runner.notification.Failure; import org.junit.jupiter.runner.notification.Failure;
public class StringInverterTest { public class StringInverterTest {
static StringInverter inverter; static StringInverter inverter;