Xunit.Net skipping tests due to duplicate ID The Next CEO of Stack Overflowxunit test Fact multiple timesRemove duplicates from a List<T> in C#In xUnit.net, is it possible to run tests in order?Ignoring Exceptions in xUnit.netTest parameterization in xUnit.net similar to NUnitHow to run setup code only once in an xUnit.net testxUnit.net - run code once before and after ALL testsxUnit.net v2 not discovering .NET Core Tests in Visual Studio 2015xUnit.net: Test class constructors not being run?Unable to Install XUnit.net in VIsualStudio 2013Running xunit.net tests in VSTS
Calculate the Mean mean of two numbers
What was Carter Burke's job for "the company" in Aliens?
AB diagonalizable then BA also diagonalizable
How to avoid supervisors with prejudiced views?
what's the use of '% to gdp' type of variables?
Can Sneak Attack be used when hitting with an improvised weapon?
How to find image of a complex function with given constraints?
I dug holes for my pergola too wide
Getting Stale Gas Out of a Gas Tank w/out Dropping the Tank
What can the phrase “is embedded in a whale of a bill” mean?
How many extra stops do monopods offer for tele photographs?
What is the difference between "hamstring tendon" and "common hamstring tendon"?
Which one is the true statement?
Is a distribution that is normal, but highly skewed, considered Gaussian?
Towers in the ocean; How deep can they be built?
Lucky Feat: How can "more than one creature spend a luck point to influence the outcome of a roll"?
Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?
Is there a reasonable and studied concept of reduction between regular languages?
Reshaping json / reparing json inside shell script (remove trailing comma)
From jafe to El-Guest
Traveling with my 5 year old daughter (as the father) without the mother from Germany to Mexico
How do I fit a non linear curve?
Why don't programming languages automatically manage the synchronous/asynchronous problem?
Redefining symbol midway through a document
Xunit.Net skipping tests due to duplicate ID
The Next CEO of Stack Overflowxunit test Fact multiple timesRemove duplicates from a List<T> in C#In xUnit.net, is it possible to run tests in order?Ignoring Exceptions in xUnit.netTest parameterization in xUnit.net similar to NUnitHow to run setup code only once in an xUnit.net testxUnit.net - run code once before and after ALL testsxUnit.net v2 not discovering .NET Core Tests in Visual Studio 2015xUnit.net: Test class constructors not being run?Unable to Install XUnit.net in VIsualStudio 2013Running xunit.net tests in VSTS
This SO answer shows code which should cause an Xunit theory test to run multiple times with this method attribute applied:
[Theory]
[Repeat(3)]
public void MyTest()
// test code here
The Repeat() attribute is defined as:
public class RepeatAttribute : DataAttribute
private readonly int _count;
public RepeatAttribute(int count)
if (count < 1)
throw new ArgumentOutOfRangeException(nameof(count), "Repeat count must be greater than 0.");
_count = count;
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
return Enumerable.Repeat(new object[0], _count);
The use case for this is to cause Xunit to run a test theory multiple times, until the data has been exhausted. For example, when the tests to be run are defined by externally-drawn data rather than specifically coded number of methods.
Unfortunately, the error this produces is:
[xUnit.net 00:00:00.55] Basic: Skipping test case with duplicate ID '071bf13109c976bcd6c61a7afa145a7a1cdb8e0a' ('Basic.Tests.MyTest()' and 'Basic.Tests.MyTest()')
[xUnit.net 00:00:00.55] Basic: Skipping test case with duplicate ID '071bf13109c976bcd6c61a7afa145a7a1cdb8e0a' ('Basic.Tests.MyTest()' and 'Basic.Tests.MyTest()')
Is there a way around this?
I have tried overriding the Skip property but either I could not find the right value for it to return or it did not have the desired effect.
[EDIT] In response to the accepted answer by @peterszabo my code now looks like this:
public class RepeatAttribute : DataAttribute
private readonly int _count;
public RepeatAttribute(int count)
if (count < 1)
throw new ArgumentOutOfRangeException(nameof(count), "Repeat count must be greater than 0.");
_count = count;
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
var list = new List<object[]>();
for (var i=1; i<=10; i++)
list.Add(new object[] i);
return list as IEnumerable<object[]>;
It is the content of the object[] in each list.Add() which will change.
c# .net-core automated-tests xunit
add a comment |
This SO answer shows code which should cause an Xunit theory test to run multiple times with this method attribute applied:
[Theory]
[Repeat(3)]
public void MyTest()
// test code here
The Repeat() attribute is defined as:
public class RepeatAttribute : DataAttribute
private readonly int _count;
public RepeatAttribute(int count)
if (count < 1)
throw new ArgumentOutOfRangeException(nameof(count), "Repeat count must be greater than 0.");
_count = count;
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
return Enumerable.Repeat(new object[0], _count);
The use case for this is to cause Xunit to run a test theory multiple times, until the data has been exhausted. For example, when the tests to be run are defined by externally-drawn data rather than specifically coded number of methods.
Unfortunately, the error this produces is:
[xUnit.net 00:00:00.55] Basic: Skipping test case with duplicate ID '071bf13109c976bcd6c61a7afa145a7a1cdb8e0a' ('Basic.Tests.MyTest()' and 'Basic.Tests.MyTest()')
[xUnit.net 00:00:00.55] Basic: Skipping test case with duplicate ID '071bf13109c976bcd6c61a7afa145a7a1cdb8e0a' ('Basic.Tests.MyTest()' and 'Basic.Tests.MyTest()')
Is there a way around this?
I have tried overriding the Skip property but either I could not find the right value for it to return or it did not have the desired effect.
[EDIT] In response to the accepted answer by @peterszabo my code now looks like this:
public class RepeatAttribute : DataAttribute
private readonly int _count;
public RepeatAttribute(int count)
if (count < 1)
throw new ArgumentOutOfRangeException(nameof(count), "Repeat count must be greater than 0.");
_count = count;
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
var list = new List<object[]>();
for (var i=1; i<=10; i++)
list.Add(new object[] i);
return list as IEnumerable<object[]>;
It is the content of the object[] in each list.Add() which will change.
c# .net-core automated-tests xunit
add a comment |
This SO answer shows code which should cause an Xunit theory test to run multiple times with this method attribute applied:
[Theory]
[Repeat(3)]
public void MyTest()
// test code here
The Repeat() attribute is defined as:
public class RepeatAttribute : DataAttribute
private readonly int _count;
public RepeatAttribute(int count)
if (count < 1)
throw new ArgumentOutOfRangeException(nameof(count), "Repeat count must be greater than 0.");
_count = count;
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
return Enumerable.Repeat(new object[0], _count);
The use case for this is to cause Xunit to run a test theory multiple times, until the data has been exhausted. For example, when the tests to be run are defined by externally-drawn data rather than specifically coded number of methods.
Unfortunately, the error this produces is:
[xUnit.net 00:00:00.55] Basic: Skipping test case with duplicate ID '071bf13109c976bcd6c61a7afa145a7a1cdb8e0a' ('Basic.Tests.MyTest()' and 'Basic.Tests.MyTest()')
[xUnit.net 00:00:00.55] Basic: Skipping test case with duplicate ID '071bf13109c976bcd6c61a7afa145a7a1cdb8e0a' ('Basic.Tests.MyTest()' and 'Basic.Tests.MyTest()')
Is there a way around this?
I have tried overriding the Skip property but either I could not find the right value for it to return or it did not have the desired effect.
[EDIT] In response to the accepted answer by @peterszabo my code now looks like this:
public class RepeatAttribute : DataAttribute
private readonly int _count;
public RepeatAttribute(int count)
if (count < 1)
throw new ArgumentOutOfRangeException(nameof(count), "Repeat count must be greater than 0.");
_count = count;
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
var list = new List<object[]>();
for (var i=1; i<=10; i++)
list.Add(new object[] i);
return list as IEnumerable<object[]>;
It is the content of the object[] in each list.Add() which will change.
c# .net-core automated-tests xunit
This SO answer shows code which should cause an Xunit theory test to run multiple times with this method attribute applied:
[Theory]
[Repeat(3)]
public void MyTest()
// test code here
The Repeat() attribute is defined as:
public class RepeatAttribute : DataAttribute
private readonly int _count;
public RepeatAttribute(int count)
if (count < 1)
throw new ArgumentOutOfRangeException(nameof(count), "Repeat count must be greater than 0.");
_count = count;
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
return Enumerable.Repeat(new object[0], _count);
The use case for this is to cause Xunit to run a test theory multiple times, until the data has been exhausted. For example, when the tests to be run are defined by externally-drawn data rather than specifically coded number of methods.
Unfortunately, the error this produces is:
[xUnit.net 00:00:00.55] Basic: Skipping test case with duplicate ID '071bf13109c976bcd6c61a7afa145a7a1cdb8e0a' ('Basic.Tests.MyTest()' and 'Basic.Tests.MyTest()')
[xUnit.net 00:00:00.55] Basic: Skipping test case with duplicate ID '071bf13109c976bcd6c61a7afa145a7a1cdb8e0a' ('Basic.Tests.MyTest()' and 'Basic.Tests.MyTest()')
Is there a way around this?
I have tried overriding the Skip property but either I could not find the right value for it to return or it did not have the desired effect.
[EDIT] In response to the accepted answer by @peterszabo my code now looks like this:
public class RepeatAttribute : DataAttribute
private readonly int _count;
public RepeatAttribute(int count)
if (count < 1)
throw new ArgumentOutOfRangeException(nameof(count), "Repeat count must be greater than 0.");
_count = count;
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
var list = new List<object[]>();
for (var i=1; i<=10; i++)
list.Add(new object[] i);
return list as IEnumerable<object[]>;
It is the content of the object[] in each list.Add() which will change.
c# .net-core automated-tests xunit
c# .net-core automated-tests xunit
edited Mar 11 at 4:59
Matt W
asked Mar 8 at 17:13
Matt WMatt W
3,3811258104
3,3811258104
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There is no variance to the input of the test. Your attribute is returning an empty object array, and your theory has no parameters, so you're basically trying to run the same test over and over again. So it gets skipped after the first execution.
If your tests' input data is
defined by externally-drawn data
then what you may want to try is let your DataAttribute read the external datasource and yield results from it. Then you can receive this data as parameters of your [Theory] method.
You can see an example of using a JSON file as an external data source for test theories on Andrew Lock's blog here.
add a comment |
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55067950%2fxunit-net-skipping-tests-due-to-duplicate-id%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is no variance to the input of the test. Your attribute is returning an empty object array, and your theory has no parameters, so you're basically trying to run the same test over and over again. So it gets skipped after the first execution.
If your tests' input data is
defined by externally-drawn data
then what you may want to try is let your DataAttribute read the external datasource and yield results from it. Then you can receive this data as parameters of your [Theory] method.
You can see an example of using a JSON file as an external data source for test theories on Andrew Lock's blog here.
add a comment |
There is no variance to the input of the test. Your attribute is returning an empty object array, and your theory has no parameters, so you're basically trying to run the same test over and over again. So it gets skipped after the first execution.
If your tests' input data is
defined by externally-drawn data
then what you may want to try is let your DataAttribute read the external datasource and yield results from it. Then you can receive this data as parameters of your [Theory] method.
You can see an example of using a JSON file as an external data source for test theories on Andrew Lock's blog here.
add a comment |
There is no variance to the input of the test. Your attribute is returning an empty object array, and your theory has no parameters, so you're basically trying to run the same test over and over again. So it gets skipped after the first execution.
If your tests' input data is
defined by externally-drawn data
then what you may want to try is let your DataAttribute read the external datasource and yield results from it. Then you can receive this data as parameters of your [Theory] method.
You can see an example of using a JSON file as an external data source for test theories on Andrew Lock's blog here.
There is no variance to the input of the test. Your attribute is returning an empty object array, and your theory has no parameters, so you're basically trying to run the same test over and over again. So it gets skipped after the first execution.
If your tests' input data is
defined by externally-drawn data
then what you may want to try is let your DataAttribute read the external datasource and yield results from it. Then you can receive this data as parameters of your [Theory] method.
You can see an example of using a JSON file as an external data source for test theories on Andrew Lock's blog here.
answered Mar 9 at 9:51
peterszabopeterszabo
7134
7134
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55067950%2fxunit-net-skipping-tests-due-to-duplicate-id%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
