Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please add label->framework #1

Closed
kristina-hager opened this issue Jan 25, 2021 · 6 comments
Closed

please add label->framework #1

kristina-hager opened this issue Jan 25, 2021 · 6 comments

Comments

@kristina-hager
Copy link

Hi there!
My team is looking into using allure reports more broadly - across many test platforms.
The allure report for some frameworks includes the framework name, as in:

  "labels": [
    {
      "name": "framework",
      "value": "junit-platform"
    },
..

It seems this info is hardcoded into the plugin as in this LOC:
https://github.com/allure-framework/allure-java/blob/5365fddefb684ca4d4abd6b43c5ec7b10f2215d3/allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java#L376

Would you be open to including a framework -> jest label in this repo?

I'm open to providing a PR myself or from my team, but I just wanted to float the idea to you first.

@mmisty
Copy link
Owner

mmisty commented Jan 27, 2021

Hi, Kristina

Maybe I didn't get you right but I think framework label is already in api:

export interface AllureReporterApi { ..... framework(framework: string): void; language(language: string): void; as_id(id: string): void; host(host: string): void; testClass(testClass: string): void; testMethod(testMethod: string): void; severity(severity: Severity): void; }

see index.ts

@kristina-hager
Copy link
Author

Yes, the api label is available. However, I believe this would require each test to use the api pass along the jest label. Is this correct?

I am asking for this label to be included in the reports by default, e.g. without any extra config beyond just including/enabling this library. The officially supported allure libraries do this.

@mmisty
Copy link
Owner

mmisty commented Jan 28, 2021

You will NOT need to add framework label to each test. You just need configure your runner once to add this label with any value you want. It can be done like it is said here https://github.com/mmisty/jest-allure2-adapter#custrom-jasmine-reporter (and then you add framework label in specStarted)

This library was created because I didn't find anything working with allure 2, so I want to keep flexibility and don't want to hardcode anything.
Thank you

@mmisty mmisty closed this as completed Jan 28, 2021
@kristina-hager
Copy link
Author

kristina-hager commented Jan 28, 2021

Ah, yes, my apologies for saying 'every test'. I meant 'every test suite'.

The solution https://github.com/mmisty/jest-allure2-adapter#custrom-jasmine-reporter would certainly work to add arbitrary labels/etc to a report coming from a test suite. If the label was very specific to that test suite, this would be very reasonable. Also I might add, this approach will be very complex to apply to thousands of test suites across hundreds of products.

In addition, framework:jest is not an arbitrary label.
This would be parity with what other allure reporters consistently add without any additional configuration required from the test code. I will include both an example from both pytest and junit5 below. There are actually considerably more fields included by default, although my focus for now is on "framework" (language would be nice too though it's kind of implied!).

Again, I am glad to contribute code to this project, if you are open to contributors.

java example of the labels:

"labels": [
    {
      "name": "host",
      "value": "IT-HOLA-02"
    },
    {
      "name": "thread",
      "value": "59625@IT-HOLA-02.Test worker(12)"
    },
    {
      "name": "framework",
      "value": "junit-platform"
    },
    {
      "name": "language",
      "value": "java"
    },
    {
      "name": "package",
      "value": "com.foo.test.BarJUnit5Test"
    },
    {
      "name": "testClass",
      "value": "com.foo.test.BarJUnit5Test"
    },
    {
      "name": "testMethod",
      "value": "testValueSourceWithSomeFailed"
    },
    {
      "name": "suite",
      "value": "com.foo.test.BarJUnit5Test"
    }
  ],

python:

  "labels": [
    {
      "name": "parentSuite",
      "value": "tests"
    },
    {
      "name": "suite",
      "value": "test_example"
    },
    {
      "name": "subSuite",
      "value": "TestCase"
    },
    {
      "name": "host",
      "value": "IT-HOLA-9"
    },
    {
      "name": "thread",
      "value": "17359-MainThread"
    },
    {
      "name": "framework",
      "value": "pytest"
    },
    {
      "name": "language",
      "value": "cpython3"
    },
    {
      "name": "package",
      "value": "tests.test_example"
    }
  ],

@mmisty
Copy link
Owner

mmisty commented Jan 29, 2021

Ok, you've convinced me. I've implemented framework, language and host labels in 0.3.7 version (https://github.com/mmisty/jest-allure2-adapter#037)

But JFYI: you will not need to setup label in every test or even in every suite (if by saying 'suite' you mean suite created after using 'describe'), you will just need to create setup file (ex. custom-reporter.ts), do setup like I wrote above and add any label you want by typing one line (and this label will be added to every test in your project)

Thank you for this issue =)

@kristina-hager
Copy link
Author

kristina-hager commented Jan 29, 2021

Yay thanks!

I am probably not using the term 'test suite' appropriately, so apologies for that. I do follow the setupfile approach and how it will work. I do deal with many, many tests across many repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants