C# 在xamarin ios上运行单元测试;不是";并行
我在xamarin.ios应用程序上有一个单元测试项目。有没有办法强制单元测试按顺序而不是并行运行 请,我不需要任何诸如“您应该以独立的方式编写单元测试”之类的建议。 我所需要的是,“是否可以使用nUnitlite并行运行测试而不是。”C# 在xamarin ios上运行单元测试;不是";并行,c#,unit-testing,xamarin,xamarin.ios,nunit,C#,Unit Testing,Xamarin,Xamarin.ios,Nunit,我在xamarin.ios应用程序上有一个单元测试项目。有没有办法强制单元测试按顺序而不是并行运行 请,我不需要任何诸如“您应该以独立的方式编写单元测试”之类的建议。 我所需要的是,“是否可以使用nUnitlite并行运行测试而不是。” [TestFixture] 公共类费用测试 { 字符串_dbPath=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),“expensemanager.db3”)
[TestFixture]
公共类费用测试
{
字符串_dbPath=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal),“expensemanager.db3”);
公共数据库设置()
{
if(File.Exists(_dbPath))
Delete(_dbPath);
var db=new SQLiteConnection(new SQLitePlatformIOS(),_dbPath);
db.CreateTable();
db.CreateTable();
变量类别=新类别()
{
Name=“category”,
计划=20
};
category.Upsert();
}
[测试]
[预期异常(类型(无效操作异常))]
public void Create_NegativeValue()
{
DbSetup();
var费用=新费用()
{
CategoryId=_CategoryId,
Description=string.Empty,
值=-10
};
expense.Upsert();
}
[测试]
[预期异常(类型(无效操作异常))]
public void Create_LongDescription()
{
DbSetup();
string description=string.Empty;
对于(int i=0;i<201;i++)
{
描述+=i;
}
var费用=新费用()
{
CategoryId=_CategoryId,
描述=描述,
值=10
};
expense.Upsert();
}
你能给我们看一份你的测试文件吗(一整堂课)?另外,您是否正在使用此属性-?@mjwills我已经用类更新了问题。您是根据什么库构建测试的?除非您自定义实现了ExpectedExceptionAttribute,否则您似乎正在使用NUnit 2.x版本。NUnit 2除了由外部项目实现的以外,没有任何并行化。是吗使用MonoTouch.NUnitLite-如前所述?或者?这就是我正在使用的
[TestFixture]
public class ExpenseTests
{
string _dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "expensemanager.db3");
public void DbSetup()
{
if (File.Exists(_dbPath))
File.Delete(_dbPath);
var db = new SQLiteConnection(new SQLitePlatformIOS(), _dbPath);
db.CreateTable<Category>();
db.CreateTable<Expense>();
var category = new Category()
{
Name = "category",
Plan = 20
};
category.Upsert();
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void Create_NegativeValue()
{
DbSetup();
var expense = new Expense()
{
CategoryId = _categoryId,
Description = string.Empty,
Value = -10
};
expense.Upsert();
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void Create_LongDescription()
{
DbSetup();
string description = string.Empty;
for (int i = 0; i < 201; i++)
{
description += i;
}
var expense = new Expense()
{
CategoryId = _categoryId,
Description = description,
Value = 10
};
expense.Upsert();
}