Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How? Logging with Specflow and xUnit 2 (ITestOutputHelper injection fails) #575

Closed
cobysy opened this issue Apr 3, 2016 · 9 comments · Fixed by #874
Closed
Labels

Comments

@cobysy
Copy link

cobysy commented Apr 3, 2016

I'm trying to log verbose information during test execution.

With xUnit 2 Console, Trace, Debug capture is no longer possible,
so we must let xUnit inject ITestOutputHelper. For example into a Specflow binding like so

public SomeSteps(ITestOutputHelper outputHelper)

but Specflow complains with the message

BoDi.ObjectContainerException Interface cannot be resolved: Xunit.Abstractions.ITestOutputHelper (resolution path: ...)

What are the methods to log information with Specflow 2 and xUnit 2 combo?
For now I've reverted back to xUnit 1.9.2, but I'd rather be using 2.0.

@reidsvilleneuve
Copy link

This is something that I am having trouble with as well. It would be nice if this ITestOutputHelper object that xUnit2 provides per-test could be made accessible though something like the ScenarioContext (I figure that the Specflow Scenario -> xUnit Fact relationship is 1:1 for the purpose of Parallelism and logging - though, there's probably a better way to do that than what I am suggesting here.)

@SabotageAndi
Copy link
Contributor

Until we include support for ITestOutputHelper for xUnit and the same for NUnit3, simple register it by your own.
Have a look at http://www.specflow.org/documentation/Context-Injection/ in the "Advanced Options" section.
Get the IObjectContainer and register the ITestOutputHelper there.

@dirkrombauts
Copy link
Contributor

We will need to extend the generator to pick up these test helper objects and pass them to the SpecFlow runtime.

@reidsvilleneuve
Copy link

SabotageAndi: Thank you very much for the reply! I actually attempted that based off of a suggestion that I found on some Stack Overflow question. Unfortunately, it appears that the ITestOutputHelper object has to be instantiated by xUnit in order for it to be used (As per bradwilson's message at xunit/xunit#815, and Avalanchis' reply at http://stackoverflow.com/questions/36363952/logging-with-specflow-and-xunit-2-itestoutputhelper). I have been contemplating a work around in the mean time - no luck on my side yet, I'm afraid.

@samholder
Copy link
Contributor

yeah I made the suggestion on stackoverflow, as usually thats a suitable solution. I also read that message at XUnit and realised that it wasn't going to be a viable solution. We discussed possible options for how this migth be implemented tonight and have some ideas (Nunit3 has a similar problem) so its just waiting for someone to get around to having enough time to look at this

@reidsvilleneuve
Copy link

Okay. That's good news. I very much appreciate your time!

avonwyss added a commit to avonwyss/SpecFlow that referenced this issue Aug 3, 2016
avonwyss added a commit to avonwyss/SpecFlow that referenced this issue Aug 4, 2016
avonwyss added a commit to avonwyss/SpecFlow that referenced this issue Nov 25, 2016
@daniellittledev
Copy link

Are there any updates as to where this issue is at?

@avonwyss
Copy link

avonwyss commented Apr 5, 2017

@lavinski There is a pull request by me from August 2016 and an update to resolve merge conflicts by @Lashas83 in February. Apparently @samholder wanted to add some additional tests but that didn't happen until now. Maybe you want to contribute some?

SabotageAndi pushed a commit that referenced this issue Jun 27, 2017
* Resolves #575 

* added tests for adding support for xUnit2 ITestOutputHelper class

added XUnit2Generator unit tests
added XUnit2Provider specs
updated XUnitExecutionDriver to output results in default (xUnit) xml
output instead of NUnit xml format

* swapped the order of the TestInitialize call and the setting of the _testOutputHelper field
Autom8edChaos added a commit to Autom8edChaos/SpecFlow that referenced this issue Nov 6, 2017
* update MSBuild.Community.Tasks to latest version via NuGet (SpecFlowOSS#801)

* Regexless stepdef fixes (SpecFlowOSS#786)

* Upgrade FluentAssertions

* Add simple unit test

* Add unit test for parametrized method

* Add unit tests for regexless - 36 failing

* fluent assertion does not allow { and } in the because part

* refine expectations: shortening like "doesn't" should not work automatically

* fix regexless matching issues

* a bit more optimal solution that produces simpler regexes

* Improve param locator

* should not remove keywords from binding culture

* small code improvements

* refine expectations: should not allow whitespace or punctuation in the front of the step text (Given !foo) in order to make the generated regex faster (does not start with rule)

* small refactor

* update changelog, remove wip tags

* add test for issue SpecFlowOSS#715

* Update changelog showing that SpecFlowOSS#301 is also fixed

* add CI NuGet package feed

* Added support for MsTest's [DeploymentItem] attribute with @mstest:DeploymentItem tag (SpecFlowOSS#805)

* Added support for MsTest's [DeploymentItem] attribute with @Deploy tag (Issue SpecFlowOSS#803)
* Prefixing new tag with `MsTest:`
* using pascal case @mstest:DeploymentItem
* wrapping nested using blocks with curly brackets

* Change project reader from MSBuild to XML (SpecFlowOSS#837)

* improve tests for project reader
* add tests for new csproj format
* change variable naming
* complete read of classic projects
* refactoring
* mark not used properties as obsolete
* support new project system & refactorings
* use AppDomainIsolatedTask instead of Task to solve file looking issues with MsBuild
* fix typo :-/
* add tests for linked files

* Added display name for theory attribution (SpecFlowOSS#812)

* Added display name for theory attribution
* Fixed incorrect namespace reference to TheoryAttribute (no longer part of extensions)

* Support context parameters on Before/After methods, FeatureContainer (SpecFlowOSS#779)

* Added scenario: Inject FeatureContext into a BeforeFeature hook
* first dummy implementation to make the scenario pass (runtime tests failing)
* Use bindingInstanceResolver to resolve parameters
* make unit tests pass
* Add unit tests for what we have so far
* support for resolving hook parameters from scenario context
* better then step for the scenarios
* fix unit test error
* added failing test for resolving objects from feature container
* refactor ScenarioContext
* Implement FeatureContainer
* move binding culture initialization to FeatureContext
* fix featurecontext resolution from scenario container
* Refactor scenario and feature context and remove displose hack that was necessary to avoid circular disposing loops
* fix unit test failure
* Make InternalContextManager to IObjectContainer reference more explicit
* rename IBindingInstanceResolver to ITestObjectResolver (breaking change for some plugins)

* Wildcard support for project reader (SpecFlowOSS#843)

* Wildcard support for project reader
* fix tests for AppVeyor

* update changelog

* Config file refactoring & Json Config file support (SpecFlowOSS#690)

* split app.config elements to multiple files

* make RuntimeConfiguration nearly immutable

* extract config loading logic to RuntimeConfigurationLoader

* reformating

* add tests for app.config reading

* move ConfigurationTest to separate Namespace

* rename file

* add json tests

* add json.net dependency

* json config file parsing

* add tests for checking which config file is used

* refactoring for tests and added tests

* remove GeneratorConfiguration

* fix dependencies for generator

* fix tests

* fix tests

* move files & fix namespaces

* work on generation config loading

* fix tests and make parsing more robust

* fix and comment test

* small cleanups

* remove ToolLanguage, GeneratorPath and DetectAmbiguousMatches from Config

rename PrintConfigSource to TraceConfigSource

* fix merge issues

* remove file

* add missing json handling

* update changelog

* add Newtonsoft.Json dependency to the NuGet package

* update TestGenerator version

* fix typo in README.md (SpecFlowOSS#853)

* fix VS code behind generation (SpecFlowOSS#855)

* fix redirects
* fix serialization problem with Visual Studio
* fix lineending

* Order sensitive overload for compare to set (SpecFlowOSS#778)

* Add tests
* Refactor TableDifferenceResults to be able to represent order sensitive diff
* make throw tests pass
* refactor message tests to be able to test order sensitive comparison
* fix diff messages for order sensitive
* Replace Tuple with TableDifferenceItem

* Hook with multiple Tags scoped are executed more than once (SpecFlowOSS#848)

* add failing tests
* Fix for SpecFlowOSS#848 Hook with multiple Tags scoped are executed more than once

* making sure that the ordering is preserved (the GroupBy might change the order)

* update changelog for 2.2.0-prerelease20170523

* add GitExtensions configuration file with github and appveyor configuration (SpecFlowOSS#862)

* Added TestThreadContext and exposed it in ContextManager and Steps base class (SpecFlowOSS#875)

* Added TestThreadContext and exposed it in ContextManager and Steps base class

* Upgrade to BoDi v1.3 (SpecFlowOSS#876)

* fix shadow copy test issue
* upgrade BoDi to v1.3
* remove unnecessary BoDi workarounds

* Adds support for xUnit2 ITestOutputHelper SpecFlowOSS#575 (SpecFlowOSS#874)

* Resolves SpecFlowOSS#575 

* added tests for adding support for xUnit2 ITestOutputHelper class

added XUnit2Generator unit tests
added XUnit2Provider specs
updated XUnitExecutionDriver to output results in default (xUnit) xml
output instead of NUnit xml format

* swapped the order of the TestInitialize call and the setting of the _testOutputHelper field

* expose TestAssembly and BindingAssemblies on ITestRunnerManager

* Fix generation from visual studio (SpecFlowOSS#877)

* rename field so that it matches the version of this class from 1.9 (which is used by VS)
* make AppConfig the default value
* add warnings

* Update for 2.2 release

* use FileStream constructor which grants ReadWrite to other processes. (SpecFlowOSS#906)

use FileStream constructor which grants ReadWrite to other processes

SpecFlowOSS#904

* Added changelog entry for PR (SpecFlowOSS#907)

* correct version number

* Access MSTest's TestContext property via ScenarioContext (SpecFlowOSS#882)

* injected MSTest's TestContext into ScenarioContext

* fixed TestContext property generation for VB.Net

* @MSBuild [DeploymentItem] - added option to provide output directory (SpecFlowOSS#901)

* @MSBuild [DeploymentItem] - added option to provide output directory

* code review

* update changelog after merging PRs SpecFlowOSS#882 & SpecFlowOSS#901

* add tests for Feature/Scenario Hooks with context parameters (SpecFlowOSS#925)

* Issue Template (SpecFlowOSS#924)

* Create issue template

* add SpecFlow+Runner to test runners

* Rename issue to ISSUE_TEMPLATE.md

* Allowed custom XSLT scripts to contain scripts.

* Updated changelog for new addition

* enter release date

* fix changelog after 2.2.1 release

* added link to Stack Overflow repro topic (SpecFlowOSS#942)

* Avoid trying to load empty configuration

* Set ConfigSource of default holder to "Default" instead of "AppConfig"

* Turn off line ending git auto conversion (SpecFlowOSS#953)

* Stop git from automatically converting line endings everytime repo is cloned
* add .vs folder to .gitignore

* Fixing copy link in step definition report (SpecFlowOSS#958)

* Update changelog

* Support for tuples (SpecFlowOSS#951)

* Initial support for Tuples
* Adding nuspec dependency
* Added tupple error when there are too many properties

* add entry for tuple

* Make scenario TestResult public (SpecFlowOSS#963)

* Make scenario TestResult public

* - Rename to ScenarioExecutionStatus
- Moved this to the root of the project
- UndefinedStep in enum
- Edited changelog.txt

* Update changelog.txt

* Single agent for unit tests execution

* Fix incorrect appveyour config

* Try to change test_script to test

* Disable automatic tests

* Provide full path to test assemblies

* Expose configuration var to batch

* Hardcoded configuration as Release

* Use %% accessor for configuration var

* Add hyperlink to discussion group (SpecFlowOSS#965)

Remove ambiguity regarding where to go for questions.
@lock
Copy link

lock bot commented Jul 9, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
7 participants