kubeshop / testkube

☸️ Kubernetes-native testing framework for test execution and orchestration
https://testkube.io
Other
1.35k stars 133 forks source link

Incomplete steps/report returned by `/executions` endpoint in case of multiple test files (junit) #4281

Open tkonieczny opened 1 year ago

tkonieczny commented 1 year ago

Based on user report - execution steps returned by /executions endpoint are incomplete if multiple test files are run. Example: 3 cypress test files were ran, the steps/report only contains one of them.

TheBrunoLopes commented 1 year ago
tkonieczny commented 1 year ago

Reproduced: https://demo.testkube.io/tests/cypress-multi-files-test/executions/64f70c1f17807111c6a9879b Example: 2 cypress test files (smoke-without-envs.cy.js, and smoke-without-envs-2.cy.js) are executed. But, /executions/64f70c1f17807111c6a9879b executionResult.steps only contans the test from the first file (smoke-without-envs.cy.js) - the test from the second one is missing. Screenshot from 2023-09-05 13-10-49

It may be related to junit TestSuite not being parsed.

vsukhin commented 1 year ago

@tkonieczny this is running command ./node_modules/cypress/bin/cypress run --reporter junit --reporter-options mochaFile=/data/repo/test/cypress/executor-tests/cypress-without-envs/results/junit.xml,toConsole=false --env

junit report file. is it the same if we execute cypress test locally?

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="0.0550" tests="1" failures="0">
  <testsuite name="Root Suite" timestamp="2023-09-11T12:57:48" tests="0" file="cypress/e2e/smoke-without-envs.cy.js" time="0.0000" failures="0">
  </testsuite>
  <testsuite name="Smoke test 1" timestamp="2023-09-11T12:57:48" tests="1" time="0.0550" failures="0">
    <testcase name="Smoke test 1 expect 1=1" time="0.0550" classname="expect 1=1">
    </testcase>
  </testsuite>
</testsuites>
vsukhin commented 1 year ago

So, junit was parsed properly, the question is, why does it contain only one script

TheBrunoLopes commented 1 year ago

@tkonieczny do you think this is an issue with our cypress executor ?

tkonieczny commented 1 year ago

Partially - looks like it's Cypress issue "feature" that report file is overwritten: https://github.com/cypress-io/cypress/issues/1824

So, based on Cypress docs (https://docs.cypress.io/guides/tooling/reporters#Merging-reports-across-spec-files) the command would need to be changed to: ./node_modules/cypress/bin/cypress run --reporter junit --reporter-options "mochaFile=/data/repo/test/cypress/executor-tests/cypress-without-envs/results/junit-[hash].xml,toConsole=false --env" (this [hash] need to be added)

I checked it locally, and multiple (two in this case) junit files are then generated: Screenshot from 2023-09-12 12-16-40

So, the cypress executor would need to have this command adjusted, and additionally we would probably need to support multiple junit files for single Test

vsukhin commented 1 year ago

ok, thank you, in this case, we have a plan:

  1. change command line
  2. support multiple junit reports
tkonieczny commented 1 year ago

Looks like it's still missing: Screenshot from 2023-10-10 16-25-05 https://demo.testkube.xyz/tests/cypress-12-executor-smoke-electron/executions/65255d9e51476cbbdca44e6b (this specific execution need to be checked because of run overwrites)

$ kubectl describe executor cypress-executor -ntestkube-integration|grep Image
  Image:  kubeshop/testkube-cypress-executor:fb932a6