From 61fb2c030bdb2f1a38a4766788a13f2b808c88f1 Mon Sep 17 00:00:00 2001 From: maxe Date: Thu, 14 Sep 2023 12:38:29 +0200 Subject: [PATCH] adjust and add further tests (#53) --- .../ecutestexecution/ETContainerTest.groovy | 59 +++++++++++++++++-- .../steps/CheckPackageStepIT.groovy | 2 +- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETContainerTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETContainerTest.groovy index edff758e..2bd07982 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETContainerTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETContainerTest.groovy @@ -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) } @@ -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 = """ @@ -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) } @@ -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 = """ diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/CheckPackageStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/CheckPackageStepIT.groovy index 5c9d300a..423957f9 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/CheckPackageStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/CheckPackageStepIT.groovy @@ -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) } }