It sounds like you want a way to extend the existing PlatformAttribute with your own code, so that you could write something like:
[Platform("SerialPortAIsAvailable")] and place it on a test or a fixture - or even at a higher level SetUpFixture. This is a major bit of work, which is planned for NUnit 3.0. In fact, we probably will replace the PlatformAttribute with something more general like [Include] and [Exclude] allowing for automatic detection of Operating System, Runtime, Culture and a few other things by NUnit, together with a way to extend it with your own tags and code. If this is the sort of thing you are after, I'll kick this bug to NUnit 3.0. If you're looking for something simpler please clarify before I do that! As a workaround, I suggest you put an Assume(SerialPortAIsAvailable) at the head of each test requiring it. This is a bit less intrusive than the code you gave above and will give an Inconclusive result when the port is not available. It will not give you a yellow bar, but you can do that by simply including one test that uses Ignore as above. By the way, I hope you have told us about whatever problems prevent you from upgrading to 2.6.2. Obviously, any fix we make for this will be in a future release, so you'll eventually want to upgrade. IME, waiting too long makes it harder. Charlie On Fri, Dec 28, 2012 at 4:46 AM, Matthias Kläy <matthias.kl...@gmx.ch> wrote: > Public bug reported: > > Hi NUnit, > > Use of categories is a great way to include/exclude tests depending on the > physical properties of the test machine. In combination with configuration > settings this feature becomes even more powerful because it allows to > configure the required physical test infrastructure, and the same tests can > be executed on different physical machines. In my case for example, settings > are: > 'SerialPortA' and 'SerialPortAIsAvailable' (e.g. COM1 and true) > 'SerialPortB' and 'SerialPortBIsAvailable' (e.g. COM2 and false) > 'SerialPortsAreInterconnected' (e.g. false) > > When running tests, I can now manually exclude those categories which cannot > be executed on the current machine. However, tests should automatically be > excluded/ignored if the test machine doesn't provide the required > infrastructure. Currently I achive this by: > if (SerialPortAIsAvailable) > <Run test case on SerialPortA> > else > Assert.Ignore("'SerialPortA' is not available, therefore this test is > ignored. Ensure that... > > This implementation requires that every test case does perform this > check. It would be much more convenient if a whole category was > automatically excluded/ignored by the NUnit test runner. I'd prefer > 'ignore' because I'd prefer to clearly see that tests were skipped and a > yellow instead of a green bar. > > 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 > Matthias > > YAT - Yet Another Terminal. > Visit YAT at http://sourceforge.net/projects/y-a-terminal/. > Contact YAT by mailto:y-a-termi...@users.sourceforge.net. > > ** Affects: nunitv2 > Importance: Undecided > Status: New > > -- > You received this bug notification because you are subscribed to NUnit > Extended Testing Platform. > https://bugs.launchpad.net/bugs/1094245 > > Title: > Means to include/exclude categories from test code > > To manage notifications about this bug go to: > https://bugs.launchpad.net/nunitv2/+bug/1094245/+subscriptions -- You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. https://bugs.launchpad.net/bugs/1094245 Title: Means to include/exclude categories from test code Status in NUnit V2 Test Framework: New Bug description: Hi NUnit, Use of categories is a great way to include/exclude tests depending on the physical properties of the test machine. In combination with configuration settings this feature becomes even more powerful because it allows to configure the required physical test infrastructure, and the same tests can be executed on different physical machines. In my case for example, settings are: 'SerialPortA' and 'SerialPortAIsAvailable' (e.g. COM1 and true) 'SerialPortB' and 'SerialPortBIsAvailable' (e.g. COM2 and false) 'SerialPortsAreInterconnected' (e.g. false) When running tests, I can now manually exclude those categories which cannot be executed on the current machine. However, tests should automatically be excluded/ignored if the test machine doesn't provide the required infrastructure. Currently I achive this by: if (SerialPortAIsAvailable) <Run test case on SerialPortA> else Assert.Ignore("'SerialPortA' is not available, therefore this test is ignored. Ensure that... This implementation requires that every test case does perform this check. It would be much more convenient if a whole category was automatically excluded/ignored by the NUnit test runner. I'd prefer 'ignore' because I'd prefer to clearly see that tests were skipped and a yellow instead of a green bar. 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 Matthias YAT - Yet Another Terminal. Visit YAT at http://sourceforge.net/projects/y-a-terminal/. Contact YAT by mailto:y-a-termi...@users.sourceforge.net. To manage notifications about this bug go to: https://bugs.launchpad.net/nunitv2/+bug/1094245/+subscriptions _______________________________________________ Mailing list: https://launchpad.net/~nunit-core Post to : nunit-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp