/
Groovy Script - User Testing.feature
52 lines (42 loc) · 1.79 KB
/
Groovy Script - User Testing.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Feature: Groovy Script - User Testing
As a developer
I want to be able to test my Groovy script
So that I get instant feedback on compilation errors/runtime errors/behaviour anomalies/etc
Scenario: I should be able to create a script, so that an action is performed
Given the script
"""
log.info('Hello world!')
"""
When I test the script
Then the validation result should be OK with message 'Hello world!'
Scenario: The plugin's package should be imported by default, so that I can make use of the 'Event' convenience class
Given the script
"""
log.info("- " + Event.JOB_STARTED)
"""
When I test the script
Then the validation result should be OK with message '- RunListener.onStarted'
Scenario: The script should be able to import external dependencies, so that I don't have to reinvent the wheel
Given the script
"""
@Grab('com.github.groovy-wslite:groovy-wslite:1.1.2')
import wslite.soap.*
log.info(SOAPClient.canonicalName)
"""
When I test the script
Then the validation result should be OK with message 'wslite.soap.SOAPClient'
Scenario: Compilation exceptions should be handled gracefully, so that Jenkins doesn't have to
Given the script with exception
"""
log.info('Hello
"""
When I test the script
Then the validation result should be ERROR with message 'An exception was caught.'
Then the validation result should be ERROR with message 'expecting ''', found '<EOF>' @ line 2, column 16.'
Scenario: Runtime exceptions should be handled gracefully, so that Jenkins doesn't have to
Given the script
"""
throw new RuntimeException('foobar')
"""
When I test the script
Then the validation result should be ERROR with message 'foobar'