karma-runner / karma-teamcity-reporter

A Karma plugin. Report results for Teamcity CI.
MIT License
34 stars 47 forks source link

Test names formatting for BDD #80

Open kottenator opened 7 years ago

kottenator commented 7 years ago

Hi!

First of all, Karma is awesome! You're doing great job! ;)

But I have a specific problem.

I use Jasmine JS test framework. For example, one of my tests:

describe("QueryDict utility", () => {
  it("should parse '?a=1&b=2' into {a: [1], b: [2]}", () => {
    expect(new QueryDict('a=1&b=2').toObject()).toEqual({a: ['1'], b: ['2']});
  });
});

It will provide the following information for the reporter:

If I use karma-teamcity-reporter, it generates the following:

##teamcity[testSuiteStarted name='QueryDict utility.Firefox 52.0.0 (Linux 0.0.0)']
##teamcity[testStarted name='should parse |'?a=1&b=2|' into {a: |[1|], b: |[2|]}']
##teamcity[testFinished name='should parse |'?a=1&b=2|' into {a: |[1|], b: |[2|]}' duration='11']
##teamcity[testSuiteFinished name='QueryDict utility.Firefox 52.0.0 (Linux 0.0.0)']

This has several problems:

image

Suite/class/test names

I don't think that suiteName + '.' + browserName is the best decision for the suite name in TC (e.g. QueryDict utility.Firefox 52.0.0 (Linux 0.0.0)).

In my example, QueryDict utility is more like a class name.

One JS test file can have more than one describe() and each describe() can contain multiple it(). It looks similar to:

And suite name is something above the test classes. Suite groups test classes. Maybe it's good to have the JS test filename as the suite name but I'm not sure that it's available in Karma reporter. So it may be e.g. the browser name.

What I suggest

So it'll look like this in TC:

image

TeamCity wrongly parses :\u0020 in test names

As you can see on my first screenshot, my test name is awfully parsed and displayed in TC tests report:

That's not your fault:

There's a bug in TC YouTrack. However, there's a workaround that may be implemented in karma-teamcity-reporter: you can replace all :\u0020 with :\u00a0 - then TeamCity will skip it.

What I suggest

Replace all :\u0020 with :\u00a0 in the test name.

Custom names formatting

Compared to karma-junit-reporter, you don't provide any way to customize suite/class/test names.

What I suggest

Please, provide a way to customize suite/class/test names e.g. similar to how it's done in karma-junit-reporter:

config.set({
  // ...
  teamcityReporter: {
    suiteNameFormatter(browser, result) {
      // ...
    },
    testNameFormatter(browser, result) {
      // ...
    }
  }
});
akaguny commented 6 years ago

Suite/class/test names +1, i`d love to group all unit tests in one suite and all describes as classes)

kottenator commented 6 years ago

ping developers? :)