SetUpFixture with parameter

Bug #809947 reported by Rechenelf
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
New
Undecided
Unassigned

Bug Description

SetUpFixture should have the same possibilities with paramater as TextFixture, so that the class can have constructors with parameters.

[TestFixture("GiantDb", "DbPass", IgnoreReason="does not work")]
[TestFixture("SmallDb", "DbPass")]

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 809947] [NEW] SetUpFixture with parameter

Please enlarge on how you would like this feature to work at runtime.

On Wed, Jul 13, 2011 at 8:20 AM, Rechenelf <email address hidden> wrote:
> Public bug reported:
>
> SetUpFixture should have the same possibilities with paramater as
> TextFixture, so that the class can have constructors with parameters.
>
> [TestFixture("GiantDb", "DbPass", IgnoreReason="does not work")]
> [TestFixture("SmallDb", "DbPass")]
>
> ** Affects: nunit-3.0
>     Importance: Undecided
>         Status: New
>
>
> ** Tags: feature
>
> --
> You received this bug notification because you are subscribed to NUnit
> Framework.
> https://bugs.launchpad.net/bugs/809947
>
> Title:
>  SetUpFixture with parameter
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunit-3.0/+bug/809947/+subscriptions
>

Revision history for this message
Rechenelf (matklaus) wrote :

Sorry for being late

[TestFixture("GiantDb", "DbPass", IgnoreReason="does not work")]
[TestFixture("SmallDb", "DbPass")]
public class MultiDbTest
{
  public MultiDbTest
(string dbName, string dbPass)
  {
    // store connection data
  }

  [SetUp]
  public SetUp()
  {
    // connect to database
  }
  ...
}

Would run all tests twice, on for GiantDb (but ignored) and for SmallDb.

So what I want to have is the same feature for the whole namespace. I don't want a database connect for every class (because does need a long time). This can I solve with a class attributed with SetUpFixture, but only for one database. I want to give more databases, something like the following. And all tests in the namespace will run twice.

[SetUpFixture ("GiantDb", "DbPass", IgnoreReason="does not work")]
[SetUpFixture ("SmallDb", "DbPass")]
public class MultiDbTest
{
  public MultiDbTest
(string dbName, string dbPass)
  {
    // store connection data
  }

  [SetUp]
  public SetUp()
  {
    // connect to database
  }
  ...
}

Is it clear?

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 809947] Re: SetUpFixture with parameter

That's clear.

It seems like we would want more than just Ignore though.
In your example, the entire suite of tests would be listed as
Ignored - however many test cases it had - and the overall
result would be a warning.

Perhaps that works in your case, but I imagine some folks
would prefer to use a Category so that the 'GiantDb' tests
could be silently skipped.

Charlie

On Thu, Jul 21, 2011 at 10:04 AM, Rechenelf <email address hidden> wrote:
> Sorry for being late
>
> [TestFixture("GiantDb", "DbPass", IgnoreReason="does not work")]
> [TestFixture("SmallDb", "DbPass")]
> public class MultiDbTest
> {
>  public MultiDbTest (string dbName, string dbPass)
>  {
>    // store connection data
>  }
>
>  [SetUp]
>  public SetUp()
>  {
>    // connect to database
>  }
>  ...
> }
>
> Would run all tests twice, on for GiantDb (but ignored) and for SmallDb.
>
> So what I want to have is the same feature for the whole namespace. I
> don't want a database connect for every class (because does need a long
> time). This can I solve with a class attributed with SetUpFixture, but
> only for one database. I want to give more databases, something like the
> following. And all tests in the namespace will run twice.
>
> [SetUpFixture ("GiantDb", "DbPass", IgnoreReason="does not work")]
> [SetUpFixture ("SmallDb", "DbPass")]
> public class MultiDbTest
> {
>  public MultiDbTest (string dbName, string dbPass)
>  {
>    // store connection data
>  }
>
>  [SetUp]
>  public SetUp()
>  {
>    // connect to database
>  }
>  ...
> }
>
> Is it clear?
>
> --
> You received this bug notification because you are subscribed to NUnit
> Framework.
> https://bugs.launchpad.net/bugs/809947
>
> Title:
>  SetUpFixture with parameter
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunit-3.0/+bug/809947/+subscriptions
>

Revision history for this message
Rechenelf (matklaus) wrote :

Oh, no, ignore is not the important thing. Just a nice add on. Ignore the ignore ;-)

The important thing is that I can specify the input data for the tests and have a constructor to store them in the setup-class. So the connection is only build once for all tests in the namepsace and not (as done with the Fixturesetup) for every class. This reduces the connection establish by about factor 100 (in our case). The build of the connection needs sometimes more time than the whole test. So we can reduce the time for all nunit-tests by more than 60%. This is the reason why.

tags: added: framework
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.