2018-11-08 13:15:15 +02:00
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.rules.ExpectedException
|
|
|
|
import org.junit.rules.RuleChain
|
|
|
|
import util.*
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.*
|
|
|
|
import static org.junit.Assert.assertThat
|
|
|
|
|
|
|
|
class KarmaExecuteTestsTest extends BasePiperTest {
|
2019-01-22 10:25:42 +02:00
|
|
|
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
2019-01-22 10:22:15 +02:00
|
|
|
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
2019-01-22 10:19:28 +02:00
|
|
|
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
2019-01-22 10:27:45 +02:00
|
|
|
private JenkinsEnvironmentRule environmentRule = new JenkinsEnvironmentRule(this)
|
2018-11-08 13:15:15 +02:00
|
|
|
private ExpectedException thrown = ExpectedException.none()
|
|
|
|
|
|
|
|
@Rule
|
|
|
|
public RuleChain rules = Rules
|
|
|
|
.getCommonRules(this)
|
|
|
|
.around(new JenkinsReadYamlRule(this))
|
2019-01-22 10:19:28 +02:00
|
|
|
.around(shellRule)
|
2019-01-22 10:22:15 +02:00
|
|
|
.around(loggingRule)
|
2019-01-22 10:27:45 +02:00
|
|
|
.around(environmentRule)
|
2019-01-22 10:25:42 +02:00
|
|
|
.around(stepRule)
|
2018-11-08 13:15:15 +02:00
|
|
|
.around(thrown)
|
|
|
|
|
|
|
|
def seleniumParams = [:]
|
|
|
|
|
|
|
|
@Before
|
|
|
|
void init() throws Exception {
|
|
|
|
helper.registerAllowedMethod("unstash", [String.class], { s -> return [s]})
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('seleniumExecuteTests', [Map.class, Closure.class], {map, body ->
|
|
|
|
seleniumParams = map
|
|
|
|
return body()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testDefaults() throws Exception {
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.karmaExecuteTests(
|
2018-11-08 13:15:15 +02:00
|
|
|
script: nullScript,
|
|
|
|
juStabUtils: utils
|
|
|
|
)
|
2019-01-22 10:19:28 +02:00
|
|
|
assertThat(shellRule.shell, hasItems(
|
2018-11-08 13:15:15 +02:00
|
|
|
containsString("cd '.' && npm install --quiet"),
|
|
|
|
containsString("cd '.' && npm run karma")
|
|
|
|
))
|
|
|
|
assertThat(seleniumParams.dockerImage, is('node:8-stretch'))
|
|
|
|
assertThat(seleniumParams.dockerName, is('karma'))
|
|
|
|
assertThat(seleniumParams.dockerWorkspace, is('/home/node'))
|
|
|
|
assertJobStatusSuccess()
|
|
|
|
}
|
2019-06-24 15:29:32 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void testMultiModules() throws Exception {
|
|
|
|
stepRule.step.karmaExecuteTests(
|
|
|
|
script: nullScript,
|
|
|
|
juStabUtils: utils,
|
|
|
|
modules: ['./ui-trade', './ui-traderequest']
|
|
|
|
)
|
|
|
|
assertThat(shellRule.shell, hasItems(
|
|
|
|
containsString("cd './ui-trade' && npm run karma"),
|
|
|
|
containsString("cd './ui-trade' && npm install --quiet")
|
|
|
|
))
|
|
|
|
assertThat(shellRule.shell, hasItems(
|
|
|
|
containsString("cd './ui-traderequest' && npm run karma"),
|
|
|
|
containsString("cd './ui-traderequest' && npm install --quiet")
|
|
|
|
))
|
|
|
|
assertJobStatusSuccess()
|
|
|
|
}
|
2018-11-08 13:15:15 +02:00
|
|
|
}
|