Open comradum opened 8 years ago
Can you show the testclass source that causes this exception? OpenCover.UI has unit tests to ensure discovery of tests work, so we might have missed your test scenario?
Please:
namespace ResultTest
{
[TestFixture]
public class TryParseNumericResult
{
public IEnumerable GetTestCases()
{
yield return
new TestCaseData(">50").SetName("Greater than 50")
.Returns(new Tuple<decimal?, ConditionType>(50, ConditionType.GREATER));
yield return
new TestCaseData("<50").SetName("Less than 50")
.Returns(new Tuple<decimal?, ConditionType>(50, ConditionType.LESS));
yield return
new TestCaseData("50").SetName("Equal to 50")
.Returns(new Tuple<decimal?, ConditionType>(50, ConditionType.EQUAL));
yield return
new TestCaseData("N50").SetName("Alphanumeric result result")
.Returns(new Tuple<decimal?, ConditionType>(null, null));
}
[Test]
[TestCaseSource("GetTestCases")]
public Tuple<decimal?, ConditionType> TestTryParseNumericResult(string value)
{
decimal? numericValue;
ConditionType conditionType;
Result.TryParseNumericResult(value, out numericValue, out conditionType);
return new Tuple<decimal?, ConditionType>(numericValue, conditionType);
}
}
}
Unfortunately I can't share all test dependencies. But test without corrections as shown above.
The same issue was reported here: #90
It might have been solved already by merging in #117 (which also already included test cases for this) Although someone reported issues with it, so we need to retest that..
See also #42
@comradum I implemented your testcode to try it, and it seems to work.
Had to add a few methods that were missing from your post. this is the class I eventually had:
` namespace OpenCover.UI.TestDiscoverer.TestResources.NUnit {
[TestFixture]
public class DynamicTestcaseTests
{
public enum ConditionType
{
GREATER,
LESS,
EQUAL
}
public IEnumerable GetTestCases()
{
yield return
new TestCaseData(">50").SetName("Greater than 50")
.Returns(new Tuple<decimal?, ConditionType>(50, ConditionType.GREATER));
yield return
new TestCaseData("<50").SetName("Less than 50")
.Returns(new Tuple<decimal?, ConditionType>(50, ConditionType.LESS));
yield return
new TestCaseData("50").SetName("Equal to 50")
.Returns(new Tuple<decimal?, ConditionType>(50, ConditionType.EQUAL));
//yield return
// new TestCaseData("N50").SetName("Alphanumeric result result")
// .Returns(new Tuple<decimal?, ConditionType>(null, null));
}
[Test]
[TestCaseSource("GetTestCases")]
public Tuple<decimal?, ConditionType> TestTryParseNumericResult(string value)
{
decimal numericValue = 50;
ConditionType conditionType = TryParseNumericResult(value);
return new Tuple<decimal?, ConditionType>(numericValue, conditionType);
}
public ConditionType TryParseNumericResult(string value)
{
char ch = value[0];
if (ch == '5')
{
return ConditionType.EQUAL;
}
if (ch == '<')
{
return ConditionType.LESS;
}
return ConditionType.GREATER;
}
}
}`
Ran this with the latest version of OpenCover and got this on screen:
So, seems to work, unless your implementation of certain methods is different. Can you try with the latest build from github?
Where I can found built binaries? Or I should build them myself? Also I have noticed that my problem already fixed, but I can't find any release with this problem fixed.
@MelleKoning, I have release version 0.8.1 installed. I see that after release there were commits on master that can fix my problem.
Are new release builds planned? If yes - when?
Hi @comradum, Yes you have to build the extension from sources. @pver do you know who can warrant a release?
Issue description:
Have exception: "Length cannot be less than zero" when start UT with TestCaseSource:
Length cannot be less than zero. Parameter name: length at System.String.Substring(Int32 startIndex, Int32 length) at OpenCover.UI.Processors.NUnitTestExecutor.ReadTestCase(XElement ts) at OpenCover.UI.Processors.NUnitTestExecutor.b1(XElement ts)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.d 66d16d 37b__1()
1.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.2.MoveNext() at System.Linq.Lookup
2.CreateForJoin(IEnumerable1 source, Func
2 keySelector, IEqualityComparer`1 comparer) at System.Linq.Enumerable.4.MoveNext() at OpenCover.UI.Processors.NUnitTestExecutor.UpdateTestMethodsExecution(IEnumerable
1 tests) at OpenCover.UI.Commands.ExecuteSelectedTestsCommand.Versions used: