Skip to content

Commit

Permalink
adjust and add further tests (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
MxEh-TT committed Sep 21, 2023
1 parent 76099ee commit 61fb2c0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ETContainerTest extends ContainerTest {
WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job)

then: "expect successful test completion"
jenkins.assertLogContains("Executing Package Checks for:", run)
jenkins.assertLogContains("Executing Package Checks for: test.pkg", run)
jenkins.assertLogContains("result: SUCCESS", run)
}

Expand Down Expand Up @@ -106,12 +106,35 @@ class ETContainerTest extends ContainerTest {
WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job)

then: "expect error"
jenkins.assertLogContains("Executing Package Checks for:", run)
jenkins.assertLogContains("Executing Package Checks for: invalid_package_desc.pkg", run)
//jenkins.assertLogContains("Description must not be empty!", run) TODO
jenkins.assertLogContains("result: ERROR", run)
jenkins.assertLogContains("-> Tools stopped successfully.", run)
}

def "Perform check on project"() {
given: "a test execution pipeline"
String script = """
node {
withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) {
ttCheckPackage testCasePath: 'invalid_package_desc.prj'
}
}
""".stripIndent()
WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline")
job.setDefinition(new CpsFlowDefinition(script, true))
jenkins.jenkins.getDescriptorByType(ETInstallation.DescriptorImpl.class)
.setInstallations(new ETInstallation('ECU-TEST',
'/bin/ecu-test', JenkinsRule.NO_PROPERTIES))
when: "scheduling a new build"
WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job)

then: "expect error"
jenkins.assertLogContains("Executing Package Checks for: invalid_package_desc.prj", run)
jenkins.assertLogContains("result: SUCCESS", run)
}


def "Perform check on project with invalid packages"() {
given: "a test execution pipeline"
String script = """
Expand All @@ -130,8 +153,8 @@ class ETContainerTest extends ContainerTest {
WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job)

then: "expect error"
jenkins.assertLogContains("Executing Package Checks for:", run)
//jenkins.assertLogContains("Description must not be empty!", run) TODO
jenkins.assertLogContains("Executing Package Checks for: invalid_package_desc.prj", run)
jenkins.assertLogContains("--> invalid_package_desc.pkg: Description must not be empty!", run)
jenkins.assertLogContains("result: ERROR", run)
jenkins.assertLogContains("-> Tools stopped successfully.", run)
}
Expand Down Expand Up @@ -188,6 +211,34 @@ class ETContainerTest extends ContainerTest {
jenkins.assertLogContains("-> Tools stopped successfully.", run)
}

def "Execute test case including package check"() {
given: "a test execution pipeline"
String script = """
node {
withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) {
ttRunPackage testCasePath: 'invalid_package_desc.pkg',
executionConfig: [executionConfig: [executePackageCheck: true, stopOnError: false]]
testConfig: [tbcPath: 'test.tbc',
tcfPath: 'test.tcf',
forceConfigurationReload: false,
constants: [[label: 'test', value: '123']]]
}
}
""".stripIndent()
WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline")
job.setDefinition(new CpsFlowDefinition(script, true))

when: "scheduling a new build"
WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job)

then: "expect successful test completion"
jenkins.assertLogContains("Executing Package Checks for: invalid_package_desc.pkg", run)
jenkins.assertLogContains("--> invalid_package_desc.pkg: Description must not be empty!", run)
jenkins.assertLogContains("Executing package invalid_package_desc.pkg", run)
jenkins.assertLogContains("result: SUCCESS", run)
jenkins.assertLogContains("reportDir: ${ET_WS_PATH}/TestReports/test_", run)
}

def "Generate report format"() {
given: "a test execution and report generation pipeline"
String script = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CheckPackageStepIT extends IntegrationTestBase {
"ttCheckPackage testCasePath: 'test.pkg', executionConfig: [timeout: 5]}", true))
expect:
WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get())
jenkins.assertLogContains("Executing Package Checks for", run)
jenkins.assertLogContains("Executing Package Checks for: test.pkg", run)
}

}

0 comments on commit 61fb2c0

Please sign in to comment.