spekt / junit.testlogger

JUnit test logger for vstest platform (<= v3.x)
MIT License
77 stars 15 forks source link

Gitlab CI number of tests is wrong #42

Closed hoppities closed 2 years ago

hoppities commented 3 years ago

Version="2.1.81"

Edit: I updated to the latest version and have the same issue.

Tests:
  image: mcr.microsoft.com/dotnet/core/sdk:3.1
  only:
    - merge_requests
    - branches
  script:
    - dotnet test --test-adapter-path:. --logger:"junit;LogFilePath=../artifacts/{assembly}-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose"
  stage: build
  artifacts:
    when: always
    reports:
      junit:
        - $CI_PROJECT_DIR/artifacts/*-result.xml

This is my test step for GitLab CI, and I have tests set up with MSTest that use parameters.

        [DataTestMethod]
        [DataRow(true)]
        [DataRow(false)]
        public async Task Some_Test_Method(bool result)
        {
            ...
        }

The results, however, don't show the parameters that are passed in, so they get combined into one test by Gitlab.

    <testcase classname="My.Test.Class.Name" name="name.Some_Test_Method" time="0.0147381" />
    <testcase classname="My.Test.Class.Name" name="name.Some_Test_Method" time="0.0118888" />
    <testcase classname="My.Test.Class.Name" name="name.Some_Test_Method" time="0.0003662" />

Expected Result: The name of the testcase will include the parameter values like the GitLab CI Documentation states.

Do I have something misconfigured?

Siphonophora commented 3 years ago

Hi, I can do some testing with MSTest, which I think may behave differently from other frameworks with regard to test data.

Based on the name of the ticket, I gather you are also seeing the issue we have here #15. There is an underlying issue with how gitlab counts tests. If that is part of what you are seeing it wouldn't hurt to upvote the gitlab issue https://gitlab.com/gitlab-org/gitlab/-/issues/31975 they have made some progress, but its been slow going.

hoppities commented 3 years ago

Hi, I can do some testing with MSTest, which I think may behave differently from other frameworks with regard to test data.

Based on the name of the ticket, I gather you are also seeing the issue we have here #15. There is an underlying issue with how gitlab counts tests. If that is part of what you are seeing it wouldn't hurt to upvote the gitlab issue https://gitlab.com/gitlab-org/gitlab/-/issues/31975 they have made some progress, but its been slow going.

Yes, I'm seeing that. I'll go upvote that and ask my coworkers to do the same :)

Siphonophora commented 3 years ago

@hoppities MSTest is, in fact, behaving differently from xunit and nunit in this regard. This impacts all our loggers, so I will fix this in the core logger, under issue https://github.com/spekt/testlogger/issues/20

Siphonophora commented 3 years ago

@hoppities I just published a fix for this to myget https://www.myget.org/feed/spekt/package/nuget/JunitXml.TestLogger/3.0.104 If you have time and can test it, let us know. I did run a test shown below.

v3.0.98

<testsuites>
  <testsuite name="TestProject1.dll" tests="17" skipped="2" failures="0" errors="0" time="0.007450599999999999" timestamp="2021-07-27T20:16:04" hostname="W0239867" id="0" package="TestProject1.dll">
    <properties />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestMethod1" time="0.0035334" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Test_Method" time="0.0018167" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Test_Method" time="0.0000478" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Test_Method" time="0.0000041" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Async_Test_Method" time="0.0002927" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Async_Test_Method" time="0.0002446" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Async_Test_Method" time="0.0000081" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.IsPrime_ValuesLessThan2_ReturnFalse" time="0.0000852" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.IsPrime_ValuesLessThan2_ReturnFalse" time="0.0000344" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.IsPrime_ValuesLessThan2_ReturnFalse" time="0.0000021" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.IsPrime_ValuesLessThan2_ReturnFalse" time="0.0000012" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestAddDynamicDataMethod" time="0.0010952" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestAddDynamicDataMethod" time="0.0000311" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestAddDynamicDataMethod" time="0.0000033" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestAddDynamicDataMethod" time="0.0000047" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.DataDrivenTest" time="0.0001306">
      <skipped />
    </testcase>
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.DataDrivenTest" time="0.0001154">
      <skipped />
    </testcase>
    <system-out></system-out>
    <system-err></system-err>
  </testsuite>
</testsuites>

MyGet preview version 3.0.104 https://www.myget.org/feed/spekt/package/nuget/JunitXml.TestLogger/3.0.104

<testsuites>
  <testsuite name="TestProject1.dll" tests="17" skipped="2" failures="0" errors="0" time="0.006163199999999999" timestamp="2021-07-27T20:22:11" hostname="W0239867" id="0" package="TestProject1.dll">
    <properties />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestMethod1" time="0.0022678" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Test_Method" time="0.0016660" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Test_Method (True)" time="0.0000527" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Test_Method (False)" time="0.0000037" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Async_Test_Method" time="0.0002872" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Async_Test_Method (True)" time="0.0002428" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.Some_Async_Test_Method (False)" time="0.0000089" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.IsPrime_ValuesLessThan2_ReturnFalse" time="0.0000888" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.IsPrime_ValuesLessThan2_ReturnFalse (-1,a)" time="0.0000360" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.IsPrime_ValuesLessThan2_ReturnFalse (0,a)" time="0.0000027" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.IsPrime_ValuesLessThan2_ReturnFalse (1,acsdf)" time="0.0000012" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestAddDynamicDataMethod" time="0.0011878" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestAddDynamicDataMethod (1,1,2)" time="0.0000334" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestAddDynamicDataMethod (12,30,42)" time="0.0000039" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.TestAddDynamicDataMethod (14,1,15)" time="0.0000014" />
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.DataDrivenTest" time="0.0001472">
      <skipped />
    </testcase>
    <testcase classname="TestProject1.UnitTest1" name="UnitTest1.DataDrivenTest" time="0.0001317">
      <skipped />
    </testcase>
    <system-out></system-out>
    <system-err></system-err>
  </testsuite>
</testsuites>
Siphonophora commented 3 years ago

@codito Two things:

hoppities commented 3 years ago

@Siphonophora We'll get this updated to the preview and let you know what happens. Thanks!

Edit: We tested this, and it's now displaying tests correctly. We're seeing the parameterized tests show up now rather than being grouped by the test method name.

Siphonophora commented 3 years ago

@hoppities Thanks for the confirmation. I will keep this open till this is published on NuGet.

BottlecapDave commented 2 years ago

Is there an update on when we might see this released? I've also been hit by this issue.

Siphonophora commented 2 years ago

@hoppities @BottlecapDave This is released in 3.0.110