•  
      request #15006 Ability to have one automated test for a feature
    Infos
    #15006
    Nicolas Terray (nterray)
    2020-06-24 09:19
    2020-06-24 09:19
    16256
    Details
    Ability to have one automated test for a feature

    Currently, when we organize a cypress spec file, we use a combination of describe/context/it:

    describe("Test plan", function () {
      context("As project member", () => {
        it("Displays no campaign nor backlog items if release does not have one", () => {
        })
        context("In a release with campaigns and backlog items", () => {
          context("Tests plan part", () => {
            it("Creates a new test", () => {
            })
          })
        })
      })
    })
    

    However in the generated junit file – that is used to mark automated tests as passed/failed – we get this:

    <testsuites name="Mocha Tests" tests="2" failures="1">
      <testsuite name="Root Suite" tests="0" file="cypress/integration/testplan.spec.ts" failures="0" time="0">
      </testsuite>
      <testsuite name="Test plan" tests="0" failures="0">
      </testsuite>
      <testsuite name="As project member" tests="1" failures="0">
        <testcase name="Test plan As project member Displays no campaign nor backlog items if release does not have one" classname="Displays no campaign nor backlog items if release does not have one">
        </testcase>
      </testsuite>
      <testsuite name="In a release with campaigns and backlog items" tests="0" failures="0" >
      </testsuite>
      <testsuite name="Test plan part" timestamp="2020-06-24T05:58:51" tests="1" failures="1" >
        <testcase name="Test plan As project member In a release with campaigns and backlog items Test plan part Creates a new test" classname="Creates a new test">
          <failure>
        </testcase>
      </testsuite>
    </testsuites>
    

    The nb of failures that are reported on the test suite prevents us to have one unique automated test. For example the top level test suite "Test plan" seems to not have a failure whereas it is the case.

    After looking at the available mocha options, we could use testsuitesTitle which default to "Mocha tests" in the root element <testsuites>. This means that with the following cypress.json:

    
    diff --git a/plugins/testplan/tests/e2e/cypress/cypress.json b/plugins/testplan/tests/e2e/cypress/cypress.json
    index 2494515860..90de099c98 100644
    --- a/plugins/testplan/tests/e2e/cypress/cypress.json
    +++ b/plugins/testplan/tests/e2e/cypress/cypress.json
    @@ -2,7 +2,8 @@
         "baseUrl": "https://tuleap",
         "reporter": "junit",
         "reporterOptions": {
    -        "mochaFile": "/output/testplan-results-[hash].xml"
    +        "mochaFile": "/output/testplan-results-[hash].xml",
    +        "testsuitesTitle": "Test plan"
         },
         "screenshotsFolder": "/output/testplan-screenshots",
         "videosFolder": "/output/testplan-videos",
    

    we would obtain:

    <testsuites name="Test plan" time="14.391" tests="6" failures="1">
      ...
    </testsuites>
    

    Here we have a way to identify if a "feature" (here Test plan) has failures in automated tests.

    However it seems that the REST route that updates automated tests does not take into account the root element <testsuites> (see TestsDataFromJunitExtractorTest). Therefore, unless you have a better idea on how to deal with this issue, we should improve the REST route first.

    Test Management
    Empty
    Empty
    • [ ] enhancement
    • [ ] internal improvement
    Empty
    Stage
    Empty
    New
    Empty
    Attachments
    Empty
    References
    References list is empty