spekt / xunit.testlogger

XUnit logger for vstest platform
MIT License
73 stars 15 forks source link

Include more information in output for better compatibility with xBehave.net #14

Closed Jazzman82 closed 5 years ago

Jazzman82 commented 5 years ago

To achieve the desired behavior described here: appccelerate/xBehaveMarkdownReport#3 or here: xbehave/xbehave.net#483 it is necessary that the DisplayName of the TestResult is printed out instead the one of the TestResult.TestCase

codito commented 5 years ago

Merged the PR. Thanks!

paulvanbladel commented 4 years ago

@Jazzman82 Did this solve for you the integration with xBehaveMarkdownReport. When I run: dotnet test --logger:xunit {so i installed xunitXml.testlogger nuget} the test names does not contain the info from the scenario test of XBehave.

Any pointer to get this working? cheers paul.

paulvanbladel commented 4 years ago

@Jazzman82 To make it more clear. This is my test:

 public class CalculatorFeature
    {
        [Trait("Category", "XBehave")] // this line must be first otherwise test result capturing won't work.
        [Scenario]
        public void Addition(int x, int y, Calculator calculator, int answer)
        {
            "Given the number 1"
                .x(() => x = 1);

            "And the number 2"
                .x(() => y = 2);

            "And a calculator"
                .x(() => calculator = new Calculator());

            "When I add the numbers together"
                .x(() => answer = calculator.Add(x, y));

            "Then the answer is 3"
                .x(() => Xunit.Assert.Equal(3, answer));
        }
    }

And this is the output:

<?xml version="1.0" encoding="UTF-8"?>

-<assemblies timestamp="12/06/2019 15:09:58">

-<assembly errors="0" time="0.005" skipped="0" failed="0" passed="5" total="5" run-time="15:09:58" run-date="2019-12-06" name="D:\TFS-PERSONAL\Gether2\GetherV2\src\Gether.Admin.IntegrationTests\bin\Debug\netcoreapp3.1\Gether.Admin.IntegrationTests.dll">

<errors/>

-<collection time="0.005" skipped="0" failed="0" passed="5" total="5" name="Test collection for Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature">

-<test time="0.0020990" name="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature.Addition" result="Pass" method="Addition" type="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature">

-<traits>

<trait name="Category" value="XBehave"/>

</traits>

</test>

-<test time="0.0000799" name="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature.Addition" result="Pass" method="Addition" type="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature">

-<traits>

<trait name="Category" value="XBehave"/>

</traits>

</test>

-<test time="0.0001417" name="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature.Addition" result="Pass" method="Addition" type="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature">

-<traits>

<trait name="Category" value="XBehave"/>

</traits>

</test>

-<test time="0.0001817" name="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature.Addition" result="Pass" method="Addition" type="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature">

-<traits>

<trait name="Category" value="XBehave"/>

</traits>

</test>

-<test time="0.0024803" name="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature.Addition" result="Pass" method="Addition" type="Gether.Admin.IntegrationTests.XbehaveTests.CalculatorFeature">

-<traits>

<trait name="Category" value="XBehave"/>

</traits>

</test>

</collection>

</assembly>

</assemblies>

I would expect that the When Given text appears somewhere in the xml. Take care paul.

paulvanbladel commented 4 years ago

@Jazzman82 Apologies for disturbing, when I installed the prelease version it worked fine. I can generate now reports with xBehaveMarkdownReport.exe as follows:

Xbehave Tests Calculator Feature
--------------------------------

### Addition

- Given the number 1
- And the number 2
- And a calculator
- When I add the numbers together
- Then the answer is 3
ursenzler commented 4 years ago

@paulvanbladel what version did you use to get the correct result? I must be blind, I see no pre-release version on nuget.org.

paulvanbladel commented 4 years ago

@ursenzler you are not blind😄. It's on myget. No access to computer right now, so can't provide more details, you need to add the myget feed in visual studio, but I presume you know this.