Skip to content

Expose attachment_url to TestCaseEntity

Max Orefice requested to merge mo-expose-attachment-to-test-report into master

Part of #202114 (closed)

What does this MR do?

Following up !26922 (merged) where we added the ability to parse an attachment attribute on our JUnit XML reports and persists it on a TestCase object.

This MR does 2 things:

  1. Exposes an attachment_url attribute as part of our TestCaseEntity behind a feature flag junit_pipeline_screenshots_view
  2. Composes the attachment_url for a given artifact

We will add filtering for a test case with attachment in a follow up MR.

Why are we adding this?

Today's problem

It's not possible to link a screenshot to a test failure. If a failure happens we need to inspect the job artifacts manually which takes time and it's a hard task for us internally.

Solution

We want to make it simple for the user to display a screenshot associated to a test failure. This way we can show a failing screenshot on a pipeline without browsing all the job artifacts manually.

Check the design for this feature.

Screenshots

Here an example payload of the test_report endpoint this feature will render:

{
  "total_time": 0.01634,
  "total_count": 1,
  "success_count": 0,
  "failed_count": 1,
  "skipped_count": 0,
  "error_count": 0,
  "test_suites": [
    {
      "name": "test",
      "total_time": 0.01634,
      "total_count": 1,
      "success_count": 0,
      "failed_count": 1,
      "skipped_count": 0,
      "error_count": 0,
      "test_cases": [
        {
          "status": "failed",
          "name": "the home page return hello world",
          "classname": "spec.hello_world_spec",
          "execution_time": 0.01634,
          "system_output": "Failure/Error: raise\nRuntimeError:\n./spec/hello_world_spec.rb:8:in `block (2 levels) in <top (required)>'",
          "stack_trace": null,
          "attachment_url": "http://127.0.0.1:3000/root/junit-test-report/-/jobs/845/artifacts/file/tmp/capybara/screenshot_return-hello-world.html"
        }
      ]
    }
  ]
}

Mozilla_Firefox_2020-03-20_13-46-34

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Max Orefice

Merge request reports