Init script
As a user I would like to be able inject a Script into a Gradle.
Total Runs | Success Rate | Failures | Errors | Skipped | Total time (ms) |
---|---|---|---|---|---|
4 | 100.0% | 0 | 0 | 0 | 0.029 seconds |
TestSubject:
Issues:
See:
- https://gradle.org
- https://docs.gradle.org/current/userguide/init_scripts.html
- io.github.gregoranders.gradle.dependencies.utilities.InitScriptCreator
Features
- should throw exception when not existent init script is provided
- should not create a temporary init script
- should remove temporary init script when close is invoked
- should return temporary init script path with replaced plugin path
should throw exception when not existent init script is provided
Result: PASS Time: 0.004 seconds
- Given an invalid init script
def initScript = '/test.gradle'
- And the unit und test provided this init script
@Subject
InitScriptCreator testSubject = new InitScriptCreator(initScript)
- When a temporary init scrip is requested
testSubject.getAbsolutePath()
- Then an exception should be thrown
thrown(NullPointerException)
should not create a temporary init script
Result: PASS Time: 0.001 seconds
- Given a valid init script
def initScript = '/gradle-dependencies-plugin.gradle'
- And the unit under test is provided this init script
@Subject
InitScriptCreator testSubject = new InitScriptCreator(initScript)
- When close is invoked on the testSubject
testSubject.close()
- Then no exceptions are thrown
noExceptionThrown()
should remove temporary init script when close is invoked
Result: PASS Time: 0.006 seconds
- Given a valid init script
def initScript = '/gradle-dependencies-plugin.gradle'
- And the unit under test is provided this init script
@Subject
InitScriptCreator testSubject = new InitScriptCreator(initScript)
- When a temporary init script is requested
def path = testSubject.getAbsolutePath()
- And the script exists
Files.exists(Path.of(path))
- And close is invoked on the testSubject
testSubject.close()
- Then the temporary init script should be deleted
!Files.exists(Path.of(path))
- And no exceptions are thrown
noExceptionThrown()
should return temporary init script path with replaced plugin path
Result: PASS Time: 0.009 seconds
- Given a valid init script
def initScript = '/gradle-dependencies-plugin.gradle'
- And the unit under test is provided this init script
@Subject
InitScriptCreator testSubject = new InitScriptCreator(initScript)
- When a temporary init script is requested
def path = testSubject.getAbsolutePath()
- Then the script exists
Files.exists(Path.of(path))
- And it contains the replaced path to the plugin
def lines = Files.readAllLines(Path.of(path))
checkPluginPath(lines)
- And it contains the replaced plugin
checkPluginName(lines)
- And close is invoked on the testSubject
testSubject.close()
- And no exceptions are thrown
noExceptionThrown()