nunit-core team mailing list archive
-
nunit-core team
-
Mailing list archive
-
Message #02922
[Bug 501784] [NEW] Theory tests do not work correctly when using null parameters
You have been subscribed to a public bug:
I am using NUnit 2.5.3. Here is some code that illustrates this bug:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace NUnitTheoryBug
{
[TestFixture]
public class TheoryBug
{
[Datapoint]
public object ObjData = null;
[Theory]
public void theory_bug(object obj) {
Assume.That(obj, Is.Null);
Assert.That(true, Is.True);
}
}
}
This is reported to me as 1 skipped and as an overall pass. There are
two problems with that.
The first problem is that it should be reported as a single pass unless
there is something I don't know about as to why there should be more
than 1 test running. Either way there should be at least one pass when
it gets passed null. I put a break point in and discovered that the
theory method only executes once, and it is passed an object that is not
null. Instead of being passed null, it is passed an object array with a
length of one, with it's only element set to null. I believe I have run
into this problem before with types other than object, but I cannot
reproduce this behavior now.
The second problem is that since the assumption never passed, the
overall result for the theory should be a fail not a pass according to
the documentation found here:
http://www.nunit.org/index.php?p=theory&r=2.5.3
I am referring to the part where it says:
"The overall result of executing a Theory over a set of test cases is
determined as follows:
If the assumptions are violated for all test cases, then the Theory
itself is marked as a failure."
** Affects: nunitv2
Importance: High
Assignee: Charlie Poole (charlie.poole)
Status: Fix Released
--
Theory tests do not work correctly when using null parameters
https://bugs.launchpad.net/bugs/501784
You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2.