I'm trying to use the NUnit framework to write some tests. The test source is:
namespace UnitTests
{
// obsolete: [NUnit.Framework.TestFixture]
public class NameSorterTests
{
public NameSorterTests () {
System.Console.WriteLine("Creating test object");
}
[NUnit.Framework.SetUp]
public void GetReady()
{
System.Console.WriteLine("starting test");
}
[NUnit.Framework.TearDown]
public void Clean()
{
System.Console.WriteLine("closing test");
}
[NUnit.Framework.Test]
public void monotonicSequence ()
{
System.Console.WriteLine("running test");
NUnit.Framework.Assert.IsTrue (true);
}
}
}
and when I try to run the tests, from the command line:
$ mcs -r:nunit.framework -target:library UnitTests.cs && nunit-console UnitTests.dll -run:blobby
Note: nunit-console shipped with Mono is deprecated, please use the NUnit
NuGet package or some other form of acquiring NUnit.
NUnit version 2.4.8
Copyright (C) 2002-2007 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.
Runtime Environment -
OS Version: Unix 4.14.12.6
CLR Version: 4.0.30319.42000 ( 5.16.0.179 (tarball Fri Nov 30 09:54:19 AEST 2018) )
Selected test: blobby
Tests run: 0, Failures: 0, Not run: 0, Time: 0.032 seconds
Note the apparently spurious -run:blobby argument; if I omit that, the Selected test: blobby line is omitted, but the rest of the output is the same. It doesn't seem to care that I specified a non-existent test. What is it doing, and how can I make it run my tests?
BTW, I don't care about the deprecation warning, so long as it just works for now; the exercise is just for a job application.
对于NUnit 2.4,需要在测试类上使用[TestFixture]
属性。
Are you sure [TestFixture] is obsolete in the NUnit you are using? What happens when you uncomment the [TestFixture] attribute on NameSorterTests?
我相信您需要在类上使用TestFixture数据属性。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.