maxbahr / specflow-trx-to-html-action

MIT License
7 stars 0 forks source link

Attachments are not included in report when using NUnit #22

Open cdapprich-bt opened 4 months ago

cdapprich-bt commented 4 months ago

The screenshots and description on Marketplace seem to indicate that any images/attachments added using the output helper will be directly included/embedded within the test results. However, this isn't the case when using the NUnit framework instead of XUnit. I don't have an example project to reproduce the issue, but I could create one if necessary.

Is this action intended to support NUnit? If so, I'd very much like this to be fixed. Thank you in advance!

maxbahr commented 2 weeks ago

Hi thanks for checking the plugin. It might happen that NUnit is not fully supported. I tested it on XUnit. I will try to check this and fix shortly.

maxbahr commented 2 weeks ago

Implementation of XUnit and NUnit for Specflow is a bit different. image

XUnit contains a log text image This is logged later in output as -> Attachment 'C:\Projects\screenshot.png' added (not forwarded to the test runner).

For NUnit this is missing.

Workaround for that is to add WriteLine command with a text starting from 'Attachment', like below. _specFlowOutput.AddAttachment(screenShotFilePath); _specFlowOutput.WriteLine("Attachment '{0}' added", screenShotFilePath);

Console output shows -> Attachment 'C:\Projects\MyProjects\specflow-nunit\SpecflowNUnit\SpecflowNUnit\bin\Debug\net8.0\AsAUserIWantToBeAbleToSearchByText\20241003_192812_screenshot.png' added

There are two conditions that needs to be met: 1) Trx contains text '-> Attachment '{path}' added 2) Attachment file is located in subfolder. ex AsAUserIWantToBeAbleToSearchByText\20241003_192812_screenshot.png
Then the report looks like this: image

To sum up, it was not a problem with the report but with Specflow NUnit implementation of logging when attachment was added.

Is there anything I can help you with? Please let my know if you have any trouble with the report implementation to your needs.