← Back to team overview

nunit-core team mailing list archive

[Bug 501784] Re: Theory tests do not work correctly when using null parameters

 

** Changed in: nunitlite
    Milestone: 1.0 => 0.9

-- 
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
https://bugs.launchpad.net/bugs/501784

Title:
  Theory tests do not work correctly when using null parameters

Status in NUnit Test Framework:
  New
Status in NUnitLite Testing Framework:
  Fix Committed
Status in NUnit V2 Test Framework:
  Fix Released

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/nunit-3.0/+bug/501784/+subscriptions