Created
August 23, 2018 00:13
-
-
Save creedasaurus/a116f3d9014e62837646e6c843dc9732 to your computer and use it in GitHub Desktop.
JUnit 5 Gradle setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.jupiter.api.Test; | |
import static org.junit.jupiter.api.Assertions.assertNotNull; | |
public class AppTest { | |
@Test public void testAppHasAGreeting() { | |
App classUnderTest = new App(); | |
assertNotNull("app should have a greeting", classUnderTest.getGreeting()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'java' | |
id 'application' | |
} | |
version = '1.0' | |
mainClassName = 'App' | |
dependencies { | |
testCompile('org.junit.jupiter:junit-jupiter-api:5.2.0') | |
testCompile('org.junit.jupiter:junit-jupiter-params:5.2.0') | |
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.2.0') | |
} | |
jar { | |
manifest { | |
attributes 'Implementation-Title': 'App', | |
'Implementation-Version': version, | |
'Main-Class': mainClassName | |
} | |
} | |
test { | |
useJUnitPlatform() | |
testLogging { | |
events "passed", "skipped", "failed" | |
} | |
} | |
repositories { | |
mavenCentral() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gradle run # run project | |
gradle test # run tests | |
gradle clean # clean out build artifacts | |
gradle build jar # build the jar file | |
java -jar ./build/libs/App-1.0.jar # run jar file using java | |
gradle clean build jar # stringing gradle commands together |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment