SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

TechTalk.SpecFlow.Tracing.NullListener for no console output not working

Open TacoVerhagen opened this issue 4 years ago • 6 comments

SpecFlow Version

3.8.7

Which test runner are you using?

MSTest

Test Runner Version Number

MSTest.TestAdapter 2.2.3

.NET Implementation

equal or greater .NET Framework 4.6.1

Project Format of the SpecFlow project

Classic project format using <PackageReference> tags

.feature.cs files are generated using

SpecFlow.Tools.MsBuild.Generation NuGet package

Test Execution Method

Visual Studio Test Explorer

SpecFlow Section in app.config or content of specflow.json

app.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<configSections>
		<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
	</configSections>
	<specFlow>
		<trace listener="TechTalk.SpecFlow.Tracing.NullListener, TechTalk.SpecFlow" />
		<bindingCulture name="nl-nl" />
		<language feature="nl-nl" />
		<stepAssemblies>
			<stepAssembly assembly="General.Framework" />
		</stepAssemblies>
	</specFlow>
</configuration>

Alternativly tried with specflow.json { "bindingCulture": { "name": "nl-nl" }, "language": { "feature": "nl-nl" }, "trace": { "listener": "TechTalk.SpecFlow.Tracing.NullListener, TechTalk.SpecFlow" }, "stepAssemblies": [ { "assembly": "General.Framework" }, ] }

Issue Description

Since this version the NullListener trace settings is NOT respected anymore. We implemented our own console output and supress the Specflow default output completely. This settings seems to have broken in the 3.7.38 to 3.8.7 update. Switching to a specflow.json setting file did not resolve the issue

Looks similair to 1723

Specflow.json error messages -> Loading plugin C:\Repos<some path>\bin\Debug\net48\TechTalk.SpecFlow.MSTest.SpecFlowPlugin.dll -> Loading plugin C:\Repos<some path>\bin\Debug\net48\Web.Tests.dll -> Missing [assembly:RuntimePlugin] attribute in Web.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Please check https://go.specflow.org/doc-plugins for details. -> Using specflow.json

app.config does not give any error message

Steps to Reproduce

Create new project Add NullListener in app.config/specflow.json Add random feature+step Run test No output should be generated in the console

Link to Repro Project

No response

TacoVerhagen avatar May 20 '21 15:05 TacoVerhagen

@ozslab & @epresi Did we break this with the new output API?

SabotageAndi avatar May 21 '21 11:05 SabotageAndi

Sorry, I somehow missed this mention... Also it was @tzongithub not @ozslab :) I will look into this, but my first thought that this should be the problem: In PR #2412, line 17 Previously the ITraceListener was a Scenario dependency, after the PR it is TestThread dependency.

epresi avatar Jun 14 '21 13:06 epresi

The problem in this issue is that the specflow.json is not accepting a listener attribute for the trace configuration element. App.config trace element specflow.json trace element There is a comment in the app.config loader, that it loads it because of "backwards compatibility".

This listener of the trace is not even documented (docs). @SabotageAndi how to continue here?

epresi avatar Jul 09 '21 05:07 epresi

Well adding the attribute and updating the documentation is not a problem (I could make the pull request). Adding another attribute 'traceNoSteps' default false is a more rigorous solution. Make the old app.config obsolete in that case? (throw a warning somewhere so people can migrate?)

The big question is, what is the general feeling for an acceptable solution? @SabotageAndi @epresi

TacoVerhagen avatar Sep 21 '21 08:09 TacoVerhagen

Please add a way to change the default trace listener back into the config. Or at least allow changing it through plugins.

ghost avatar May 05 '22 08:05 ghost

+1 For registering custom trace listener easily. Currrently SpecFlow does expose much configurability on logging, even adding a DateTime seems a lot of work.

Having a custom trace listener would simplify this

stevozilik avatar Jan 23 '24 08:01 stevozilik