Theory tests do not work correctly when using null parameters

Bug #501784 reported by Jesse Dickey
4
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
Fix Released
High
Charlie Poole
NUnit V2
Fix Released
High
Charlie Poole
NUnitLite
Fix Released
High
Charlie Poole

Bug Description

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."

Changed in nunitv2:
status: New → Triaged
importance: Undecided → High
Changed in nunitv2:
milestone: none → 2.5.4
Changed in nunitv2:
assignee: nobody → Charlie Poole (charlie.poole)
Changed in nunitv2:
status: Triaged → Fix Committed
Changed in nunitv2:
status: Fix Committed → Fix Released
affects: nunitv2 → nunitlite
Changed in nunitlite:
milestone: 2.5.4 → none
affects: nunitlite → nunitv2
Changed in nunitlite:
status: New → In Progress
importance: Undecided → High
assignee: nobody → Charlie Poole (charlie.poole)
milestone: none → 1.0
Changed in nunitv2:
milestone: none → 2.5.4
Changed in nunitlite:
status: In Progress → Fix Committed
Changed in nunitlite:
milestone: 1.0 → 0.9
Changed in nunit-3.0:
status: New → Triaged
importance: Undecided → High
Changed in nunit-3.0:
milestone: none → 2.9.6
Changed in nunitlite:
status: Fix Committed → Fix Released
Changed in nunit-3.0:
assignee: nobody → Charlie Poole (charlie.poole)
status: Triaged → Fix Committed
Changed in nunit-3.0:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.