Created
October 23, 2017 06:54
-
-
Save askalee/f2f489cff739fad341248864aafe0d4b to your computer and use it in GitHub Desktop.
Run unit test each time before the main script runs
This file contains hidden or 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
def RunUnitTests() { | |
println("INFO: Running Unit Tests") | |
def tests = [:] | |
// define unit tests here | |
tests["GetNodesByLabel"] = { | |
assert GetNodesByLabel().collect{it.name}.size() > 0 | |
} | |
// end of define unit tests | |
tests.each {testName, testScript -> | |
println("UNITTEST [${testName}]: Run...") | |
testScript() | |
println("UNITTEST [${testName}]: Passed") | |
} | |
println("INFO: End of Unit Tests, all tests should have passed") | |
} | |
RunUnitTests() | |
if(build.buildVariableResolver.resolve("HandleUnitTests") == "TestOnly"){ | |
println("WARNING: Run tests only, skip running main script") | |
return 0 | |
} | |
// Put main script here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment