← Back to team overview

nunit-core team mailing list archive

[Bug 1091485] [NEW] The TestCaseSourceAttribute should allow to set multiple categories using .SetCategory or .SetCategories

 

Public bug reported:

Hi NUnit,

Use of the TestCaseSourceAttribute together with yield is a great way to
generate test vectors. However, in some cases, a certain test may have
multiple categories applied, in my case for example
'SerialPortAIsAvailable' + 'SerialPortBIsAvailable' +
'SerialPortsAreInterconnected'. This currently cannot be achieved using
.SetCategory() because that method only takes a single string as an
argument. I therefore suggest to either provide a .SetCategory() method
that takes a string array as an argument, or the add a new method
.SetCategories() that does the same.

Example code:
foreach (KeyValuePair<TransmissionType, string> kvp in TransmissionTypes.GetItems)
{
    yield return (new TestCaseData(kvp.Key, SingleLineCommand, 1).SetCategory(kvp.Value).SetName(kvp.Key + "_SingleLineTransmission"));
    yield return (new TestCaseData(kvp.Key, DoubleLineCommand, 1).SetCategory(kvp.Value).SetName(kvp.Key + "_DoubleLineTransmission"));
   yield return (new TestCaseData(kvp.Key, DoubleLineCommand, 2).SetCategory(kvp.Value).SetName(kvp.Key + "_DoubleLineDoubleTransmission"));
   ...

Currently using:
> NUnit 2.5.10 (not yet upgraded to 2.6.2 due to the fact that the upgrade lead to issues with .NET 3.5)
> Gui Runner

Best regards & Thanks a lot for NUnit being such a great tool!
Matthias

YAT - Yet Another Terminal.
Visit YAT at http://sourceforge.net/projects/y-a-terminal/.
Contact YAT by mailto:y-a-terminal@xxxxxxxxxxxxxxxxxxxxx.

** Affects: nunitv2
     Importance: Undecided
         Status: New


** Tags: feature

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

Title:
  The TestCaseSourceAttribute should allow to set multiple categories
  using .SetCategory or .SetCategories

Status in NUnit V2 Test Framework:
  New

Bug description:
  Hi NUnit,

  Use of the TestCaseSourceAttribute together with yield is a great way
  to generate test vectors. However, in some cases, a certain test may
  have multiple categories applied, in my case for example
  'SerialPortAIsAvailable' + 'SerialPortBIsAvailable' +
  'SerialPortsAreInterconnected'. This currently cannot be achieved
  using .SetCategory() because that method only takes a single string as
  an argument. I therefore suggest to either provide a .SetCategory()
  method that takes a string array as an argument, or the add a new
  method .SetCategories() that does the same.

  Example code:
  foreach (KeyValuePair<TransmissionType, string> kvp in TransmissionTypes.GetItems)
  {
      yield return (new TestCaseData(kvp.Key, SingleLineCommand, 1).SetCategory(kvp.Value).SetName(kvp.Key + "_SingleLineTransmission"));
      yield return (new TestCaseData(kvp.Key, DoubleLineCommand, 1).SetCategory(kvp.Value).SetName(kvp.Key + "_DoubleLineTransmission"));
     yield return (new TestCaseData(kvp.Key, DoubleLineCommand, 2).SetCategory(kvp.Value).SetName(kvp.Key + "_DoubleLineDoubleTransmission"));
     ...

  Currently using:
  > NUnit 2.5.10 (not yet upgraded to 2.6.2 due to the fact that the upgrade lead to issues with .NET 3.5)
  > Gui Runner

  Best regards & Thanks a lot for NUnit being such a great tool!
  Matthias

  YAT - Yet Another Terminal.
  Visit YAT at http://sourceforge.net/projects/y-a-terminal/.
  Contact YAT by mailto:y-a-terminal@xxxxxxxxxxxxxxxxxxxxx.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nunitv2/+bug/1091485/+subscriptions


Follow ups

References