Using skip feature with XUnit InlineData attribute throws InvalidOperationException
See original GitHub issueDescription
Adding a Skip parameter to XUnit InlineData attribute is throwing the below error:
Message: System.InvalidOperationException : TestOutput is not provided. Ensure that scenario is executed from method with [Scenario] attribute, or ITestOutputHelper instance is provided to FeatureFixture constructor.
Example of Scenario:
public class AdditionFeature: FeatureFixture
{
[InlineData(1,2, 3, Skip = "Skip this scenario because its faulty.")]
[Scenario]
public async Task Scenario_test_one_plus_two(int firstNumber, int secondNumber, int expectedResult)
=> await Runner.WithContext<TestContext>()
.AddSteps(
given => given.Two_numbers_are_inputted.(firstnumber, secondnumber))
.AddAsyncSteps(
when => when.The_two_numbers_are_added())
.AddSteps(
then => then.The_two_numbers_should_be_EXPECTEDRESULT(expectedResult))
.RunAsync();
}
Progress
- Feature is implemented,
- Ensured backward-compatibility,
- Ensured good debugging experience
- Wiki page is updated
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
Skip Fact/Theory when precondition is not satisfied
When the method lands in the catch it sets the Skip attribute and the test is skipped and shown as such in the...
Read more >Skip ignored on xunit theory InlineData : RSRP-475671
When trying to skip a specific xunit test case by placing a Skip value on an InlineData attribute, the test is executed anyway....
Read more >Unit Testing with C# and .NET (Full Guide) - Sergey Drozdov
xUnit provides options to facilitate this: Skipping tests: Use the Skip parameter on the [Fact] or [Theory] attributes to skip a test.
Read more >Why did we build xUnit 1.0?
Sometimes, the excessive use of attributes can make you feel like you've diverged far from the underlying language. xUnit.net removed some attributes from...
Read more >C# Quicktip: In Xunit how to skip a unit test from being run
When you have the ignore attribute above a testmethod the test will be skipped. For example: [TestMethod] [Ignore] public void ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @krt-c ,
Thanks for reporting it. I have to take a look at the details and will come back to you. For the time being pese use
[IgnoreScenario()]
described hereList of changes:
Skip
property onScenarioAttribute
as well asInlineDataAttribute
, allow the test to run but make it ignored as soon as executed withRunner
, so that outcome is included in the reportsUseXUnitSkipBehaviorAttribute
that could enforce default xunit behavior.The tests no longer fail when
[InlineData]
is used withSkip
property.The feature has been tested in:
Assuming the following code:
Before the change, the skipped tests were not present in the reports (and
[InlineData]
withSkip
property were causing runtime issues):With the change, the skipped tests are included in the reports:
Please note that even though the Scenario is marked as
Ignored
, the test method is effectively executed, especially any code up toRunner.RunScenario()
. In case when this behavior is undesired, the native xunit treatment of skipped tests can be restored by adding[assembly: UseXUnitSkipBehavior]
to the test project.