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.030 seconds |
TestSubject:
Issues:
See:
- https://gradle.org
- https://docs.gradle.org/current/userguide/init_scripts.html
- io.github.gregoranders.idea.gradle.dependencies.gradle.utilities.InitScriptInjector
Features
- should return temporary init script path with replaced plugin path
- should remove temporary init script when close is invoked
- should not create a temporary init script
- should throw exception when not existent init script is provided
should return temporary init script path with replaced plugin path
Result: PASS Time: 0.020 seconds
- Given a valid init script
def initScript = '/gradle-dependencies-plugin.gradle'
- And the unit under test is provided this init script
@Subject
InitScriptInjector testSubject = new InitScriptInjector(initScript, 'plugin')
- 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, 'plugin')
- And close is invoked on the testSubject
testSubject.close()
- And no exceptions are thrown
noExceptionThrown()
should remove temporary init script when close is invoked
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
InitScriptInjector testSubject = new InitScriptInjector(initScript, 'test')
- 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 not create a temporary init script
Result: PASS Time: 0
- Given a valid init script
def initScript = '/gradle-dependencies-plugin.gradle'
- And the unit under test is provided this init script
@Subject
InitScriptInjector testSubject = new InitScriptInjector(initScript, 'test')
- When close is invoked on the testSubject
testSubject.close()
- Then no exceptions are thrown
noExceptionThrown()
should throw exception when not existent init script is provided
Result: PASS Time: 0
- Given an invalid init script
def initScript = '/test.gradle'
- And the unit und test provided this init script
@Subject
InitScriptInjector testSubject = new InitScriptInjector(initScript, 'test')
- When a temporary init scrip is requested
testSubject.getAbsolutePath()
- Then an exception should be thrown
thrown(NullPointerException)