NUnit 测试项目未找到任何测试
NUnit Test project not finding any tests
我是 NUnit 测试的新手,由于某种原因,在尝试设置全局变量时,程序丢失了对所有测试的所有引用。我认为这是因为我试图以错误的方式创建全局变量。任何正确方向的提示都会有所帮助。
这是代码片段。
using System;
using JMS;
using System.IO;
using NUnit.Framework;
namespace JMSTest {
[TestFixture]
public class JMSTests {
private JMSForm testJMS { get { return new JMSForm(); } }
private string[] goodFileList = new string[] { ".DLD", ".STA", ".TIF", ".DFC", ".PDF" };
private string[] ignoreFileList = new string[] { ".INI", ".RBK" };
[Test]
public void TestCreateConnectionStringBlank() {
string testString = testJMS.createConnectionString("", "", "", "");
Assert.AreEqual(testString, "server=;database=;uid=;password=");
}
[Test]
public void TestCreateConnectionStringProper() {
string testString = testJMS.createConnectionString("1", "2", "3", "4");
Assert.AreEqual(testString, "server=1;database=2;uid=3;password=4");
}
我得到的结果是:
------ Discover test started ------
========== Discover test finished: 0 found (0:00:00.037) ==========
我也试过了
public class JMSTests {
private static JMSForm testJMS;
private static string[] goodFileList;
private static string[] ignoreFileList;
[SetUpFixture]
public class before_tests_run {
[SetUp]
public void ControllerASetup() {
var testJMS = new JMSForm();
var goodFileList = new string[] { ".DLD", ".STA", ".TIF", ".DFC", ".PDF" };
var ignoreFileList = new string[] { ".INI", ".RBK" };
}
}
如果您使用的是 NUnit3+
版本,则可以使用新的测试适配器。
转到
Tools -> Extensions and Updates -> Online" and search for "NUnit3 Test
Adapter
然后安装它。然后你就可以运行测试了。
我是 NUnit 测试的新手,由于某种原因,在尝试设置全局变量时,程序丢失了对所有测试的所有引用。我认为这是因为我试图以错误的方式创建全局变量。任何正确方向的提示都会有所帮助。
这是代码片段。
using System;
using JMS;
using System.IO;
using NUnit.Framework;
namespace JMSTest {
[TestFixture]
public class JMSTests {
private JMSForm testJMS { get { return new JMSForm(); } }
private string[] goodFileList = new string[] { ".DLD", ".STA", ".TIF", ".DFC", ".PDF" };
private string[] ignoreFileList = new string[] { ".INI", ".RBK" };
[Test]
public void TestCreateConnectionStringBlank() {
string testString = testJMS.createConnectionString("", "", "", "");
Assert.AreEqual(testString, "server=;database=;uid=;password=");
}
[Test]
public void TestCreateConnectionStringProper() {
string testString = testJMS.createConnectionString("1", "2", "3", "4");
Assert.AreEqual(testString, "server=1;database=2;uid=3;password=4");
}
我得到的结果是:
------ Discover test started ------
========== Discover test finished: 0 found (0:00:00.037) ==========
我也试过了
public class JMSTests {
private static JMSForm testJMS;
private static string[] goodFileList;
private static string[] ignoreFileList;
[SetUpFixture]
public class before_tests_run {
[SetUp]
public void ControllerASetup() {
var testJMS = new JMSForm();
var goodFileList = new string[] { ".DLD", ".STA", ".TIF", ".DFC", ".PDF" };
var ignoreFileList = new string[] { ".INI", ".RBK" };
}
}
如果您使用的是 NUnit3+
版本,则可以使用新的测试适配器。
转到
Tools -> Extensions and Updates -> Online" and search for "NUnit3 Test Adapter
然后安装它。然后你就可以运行测试了。