C# NUnit没有找到测试
我试着用Mono、C#和NUnit建立一个项目 我试图让测试运行,所以我构建了一个MSBuild/xbuildC# NUnit没有找到测试,c#,msbuild,mono,nunit,C#,Msbuild,Mono,Nunit,我试着用Mono、C#和NUnit建立一个项目 我试图让测试运行,所以我构建了一个MSBuild/xbuildTest.csproj文件: <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGro
Test.csproj
文件:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<OutputPath>bin</OutputPath>
<AssemblyName>Test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit\lib\net45\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Test.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\mainproj.csproj">
<Name>Mainproj</Name>
</ProjectReference>
</ItemGroup>
</Project>
什么有效?
- Test.dll已成功编译
nunit-console4-bin/nunit.framework.dll-bin/Test.dll
未找到任何测试:
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 15.0.0.0
CLR Version: 4.0.30319.17020 ( 4.2.1 (Stable 4.2.1.102/6dd2d0d Wed Dec 2 14:02:18 PST 2015) )
Tests run: 0, Failures: 0, Not run: 0, Time: 0.055 seconds
NUnit版本2.4.8
版权所有(C)2002-2007 Charlie Poole。
版权所有(C)2002-2004詹姆斯·W·纽柯克,迈克尔·C·二,阿列克谢·A·沃龙佐夫。
版权所有(C)2000-2002菲利普·克雷格。
版权所有。
运行时环境-
操作系统版本:Unix 15.0.0.0
CLR版本:4.0.30319.17020(4.2.1(稳定的4.2.1.102/6dd2d0d星期三12月2日14:02:18太平洋标准时间2015))
测试运行:0,失败:0,未运行:0,时间:0.055秒
将测试用例属性命名为“test”(而不是“TestCase”): 更新代码: 测试的输出示例: 注意:没有理由将
nunit.framework.dll
传递给nunit-console4
,因为它将被扫描以进行没有任何测试
Ref:将您的测试用例属性命名为“test”(而不是“TestCase”): 更新代码: 测试的输出示例: 注意:没有理由将
nunit.framework.dll
传递给nunit-console4
,因为它将被扫描以进行没有任何测试
参考:太好了,这就是问题所在。顺便说一句,
[Test]
和[Test()]
之间有区别吗,似乎[Test]
工作得很好,所以我想它会隐式调用Test()
[Test]工作得很好,这是我的习惯。。。i、 e.[Test(ExpectedResult=“StackOverflow”)],如果缺少,我的代码格式化程序会添加它…;-)太好了,这就是问题所在。顺便说一句,[Test]
和[Test()]
之间有区别吗,似乎[Test]
工作得很好,所以我想它会隐式调用Test()
[Test]工作得很好,这是我的习惯。。。i、 e.[Test(ExpectedResult=“StackOverflow”)],如果缺少,我的代码格式化程序会添加它…;-)
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 15.0.0.0
CLR Version: 4.0.30319.17020 ( 4.2.1 (Stable 4.2.1.102/6dd2d0d Wed Dec 2 14:02:18 PST 2015) )
Tests run: 0, Failures: 0, Not run: 0, Time: 0.055 seconds
using NUnit.Framework;
namespace Foo.Test {
[TestFixture ()]
public class TestClass
{
[Test ()]
public void AddTest()
{
Assert.AreEqual(30, 15 + 15);
}
[Test ()]
public void Minus()
{
Assert.AreEqual(30, 15 - 15);
}
}
}
$> nunit-console4 Test.dll
NUnit version 2.4.8
~~~~
..F
Tests run: 2, Failures: 1, Not run: 0, Time: 0.120 seconds
Test Case Failures:
1) Foo.Test.TestClass.Minus : Expected: 30