@@ -0,0 +1,20 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.Narrative
|
||||
import spock.lang.Specification
|
||||
import spock.lang.Title
|
||||
|
||||
|
||||
@Title("""This title is easy to read for humans""")
|
||||
class CustomTitleTest extends Specification {
|
||||
|
||||
}
|
||||
|
||||
@Narrative("""
|
||||
as a user
|
||||
i want to save favourite items
|
||||
and then get the list of them
|
||||
""")
|
||||
class NarrativeDescriptionTest extends Specification {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.IgnoreIf
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
class IgnoreIfTest extends Specification {
|
||||
|
||||
@IgnoreIf({System.getProperty("os.name").contains("windows")})
|
||||
def "I won't run on windows"() { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.IgnoreRest
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
class IgnoreRestTest extends Specification {
|
||||
|
||||
def "I won't run"() { }
|
||||
|
||||
@IgnoreRest
|
||||
def 'I will run'() { }
|
||||
|
||||
def "I won't run too"() { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.Ignore
|
||||
import spock.lang.Specification
|
||||
|
||||
@Ignore
|
||||
class IgnoreTest extends Specification {
|
||||
|
||||
@Ignore
|
||||
def "I won't be executed"() {
|
||||
expect:
|
||||
true
|
||||
}
|
||||
|
||||
def 'Example test'() {
|
||||
expect:
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
class IssueTest extends Specification {
|
||||
|
||||
|
||||
@Issue("http://jira.org/issues/LO-531")
|
||||
def 'single issue'() {
|
||||
}
|
||||
|
||||
@Issue(["http://jira.org/issues/LO-531", "http://jira.org/issues/LO-123"])
|
||||
def 'multiple issues'() {
|
||||
}
|
||||
|
||||
@Issue("LO-1000")
|
||||
def "I'm using Spock configuration file"() {
|
||||
expect:
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.PendingFeature
|
||||
|
||||
class PendingFeatureTest {
|
||||
|
||||
@PendingFeature
|
||||
def 'test for not implemented yet feature'() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.Requires
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
class RequiresTest extends Specification {
|
||||
|
||||
@Requires({ System.getProperty("os.name").contains("windows") })
|
||||
def "I will run only on Windows"() {
|
||||
expect:
|
||||
true
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.Specification
|
||||
import spock.util.environment.RestoreSystemProperties
|
||||
|
||||
|
||||
class RestoreSystemPropertiesTest extends Specification {
|
||||
|
||||
@RestoreSystemProperties
|
||||
def 'all environment variables will be saved before execution and restored after tests'() {
|
||||
given:
|
||||
System.setProperty('os.name', 'Mac OS')
|
||||
|
||||
expect:
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.Retry
|
||||
import spock.lang.Specification
|
||||
|
||||
@Retry
|
||||
class RetryTest extends Specification {
|
||||
|
||||
@Retry
|
||||
def 'I will retry three times'() { }
|
||||
|
||||
@Retry(exceptions = [RuntimeException])
|
||||
def 'I will retry only on RuntimeException'() { }
|
||||
|
||||
@Retry(condition = { failure.message.contains('error') })
|
||||
def 'I will retry with a specific message'() { }
|
||||
|
||||
@Retry(delay = 1000)
|
||||
def 'I will retry after 1000 millis'() { }
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.See
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
class SeeTest extends Specification {
|
||||
|
||||
|
||||
@See("https://example.org")
|
||||
def 'Look at the reference'() {
|
||||
|
||||
}
|
||||
|
||||
@See(["https://example.org/first", "https://example.org/first"])
|
||||
def 'Look at the references'() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package extensions
|
||||
|
||||
import org.junit.Ignore
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
class StackTraceTest extends Specification {
|
||||
|
||||
def 'stkacktrace'() {
|
||||
// expect:
|
||||
// throw new RuntimeException("blabla")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.Specification
|
||||
import spock.lang.Stepwise
|
||||
|
||||
|
||||
@Stepwise
|
||||
class StepwiseTest extends Specification {
|
||||
|
||||
def 'I will run as first'() { }
|
||||
|
||||
def 'I will run as second'() { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package extensions
|
||||
|
||||
import mocks.ItemService
|
||||
import spock.lang.Specification
|
||||
import spock.lang.Subject
|
||||
|
||||
|
||||
class SubjectTest extends Specification {
|
||||
|
||||
@Subject
|
||||
ItemService itemService // initialization here...
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package extensions
|
||||
|
||||
import spock.lang.Specification
|
||||
import spock.lang.Timeout
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@Timeout(5)
|
||||
class TimeoutTest extends Specification {
|
||||
|
||||
@Timeout(1)
|
||||
def 'I have one second to finish'() {
|
||||
|
||||
}
|
||||
|
||||
def 'I will have 5 seconds timeout'() {}
|
||||
|
||||
@Timeout(value = 200, unit = TimeUnit.SECONDS)
|
||||
def 'I will fail after 200 millis'() {
|
||||
expect:
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import extensions.TimeoutTest
|
||||
import spock.lang.Issue
|
||||
|
||||
runner {
|
||||
filterStackTrace true
|
||||
|
||||
report {
|
||||
issueNamePrefix 'Bug '
|
||||
issueUrlPrefix 'http://jira.org/issues/'
|
||||
}
|
||||
|
||||
optimizeRunOrder true
|
||||
|
||||
// exclude TimeoutTest
|
||||
// exclude {
|
||||
// baseClass TimeoutTest
|
||||
// annotation Issue
|
||||
// }
|
||||
|
||||
report {
|
||||
enabled true
|
||||
logFileDir '.'
|
||||
logFileName 'report.json'
|
||||
logFileSuffix new Date().format('yyyy-MM-dd')
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user