•  
      request #28291 fix flaky Baseline integration test
    Infos
    #28291
    Joris MASSON (jmasson)
    2022-09-12 13:58
    2022-09-09 10:55
    29867
    Details
    fix flaky Baseline integration test

    Randomly, the integration test \Tuleap\Baseline\REST\BaselineArtifactControllerIntTest::testGetWithoutQuery would fail, with an obscure comparison error:

    Tuleap\Baseline\REST\BaselineArtifactControllerIntTest::testGetWithoutQuery
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -'epic #9'
    +'artifact title'
    

    It is obscure because in the test itself, the actual artifact seems to be created with the expected title. It turns out the test builder for baseline artifacts had some static state, where it would keep track of the artifact ID and auto-increment it. Depending on the order in which tests are run, it could happen that it would create 9 artifacts. The code would then find the "automatically created" artifact with id #9 instead of the manually created one, leading to the comparison error.

    In summary: avoid state in test builders. They should be stateless and pure. Set IDs manually if they are important for the test. Don't rely on state, as it will affect other tests.

    Dev tools
    Empty
    Empty
    • [ ] enhancement
    • [x] internal improvement
    Empty
    Stage
    Joris MASSON (jmasson)
    Closed
    2022-09-12
    Attachments
    Empty
    References
    Referencing request #28291

    Follow-ups