TeamCity - rspec specs do not give correct number of tests in TC build

In rspec you would write your tests like this: 

```describe 'A Model' do

   context 'B definition' do

        it 'C test' do

        end

    end

end```

In TC the test run and in the build log, it logs the test like this:  [B definition] C test

This is causing problems with calculating the correct number of tests as the are seen as duplicates.
There are other model specs with different model names but the same definition and test. 

No code changes just running the specs on TC and the number varies each run: (the correct number should be 6362)

 

 

 

Even though both specs come from different folders and testing different things. 

0
2 comments
Avatar
Permanently deleted user

I have done some more reading and if you use a custom rake task it calculates the correct number of specs. It does however not calculate if the specific test has the same test name as another in the same file - then TeamCity will process it as a duplicate. Rspec does not do this and will calculate the spec irrespective of its name, so should still be looked in by TeamCity. If you do come across that rspec on local and on TC test count does not agree look at the test link on a specific build in TC and it will tell you which was run twice. Pretty easy in finding the duplicate name of the test. 

The rspec rake task: 

```

namespace :teamcity do
  task parallel_rspec: :environment do
    sh('parallel_rspec spec --serialize-stdout')
  end
end

```

 

0

Hi Concetta,

I see the point you are making. Could you report that to our issue tracker https://youtrack.jetbrains.com/issues/TW? I'm not sure there is an easy way to fix it other than your rspec rake task as of now, and it's problematic for our test processing engine to have duplicate names in a same file that are actually different tests, so I can't confirm this would get fixed any time soon, but without reporting it, it definitely won't be.

You can also, in the tests tab, select the grouping of tests under the "View" dropdown, including an option to not group them by name, but I can't currently confirm that it would do your trick for rspec, and it definitely would not change the final build status message.

It is in any case strange that the number of tests are different for every run, if they all have the same code, unless you have a set of flaky tests or there were some actual changes. Could you confirm that it's not related to the code nor flaky tests?

0

Please sign in to leave a comment.