我们当前的项目涉及构建一个由 .Net 应用程序控制的机器人盒子。我们与相当多的硬件库进行交互,并且我们确实设置了一个集成服务器,所有硬件都连接到它来运行夜间回归测试。
不幸的是,并非系统中的所有硬件库都能与 TFS 和 MSTest 很好地集成。
当我们使用某个库运行构建和测试时,我们会出现以下两种行为之一:
- 所有测试均标记为已通过
TFS 但构建显示为
部分成功。
- TFS 显示没有测试运行,但日志显示所有测试均已通过,构建标记为部分成功。
查看日志,在测试发布到 TFS 服务器后我们可以看到这两行,
“处理 MSTest 异常”
“MSTest.exe 返回了一个退出代码 0表明并非所有测试都通过”
真正让我困惑的是,从命令行使用 mstest 运行相同的测试不会显示此问题。此外,当从命令行运行时,MsTest当所有测试通过时返回 0,当出现错误时返回 1
所以我的问题是:
- 成功/失败时相应的 MSTest 返回代码是什么
- 除了Visual Studio中的登录之外,还有其他详细的登录功能吗?
- 有知道去哪里看的线索吗?
附加信息:我们确实注意到在 mstest 中使用(或不使用)“NoIsolation”标志时存在差异。使用该标志时,特定测试将通过,但其他测试将失败......我们仍在调查该测试。
Thanks
编辑:日志的相关部分:
30/30 测试通过
Summary
-------
Test Run Completed.
Passed 30
----------
Total 30
Results file: C:\Builds\1\Galil Daily build\TestResults\D201364-W7$_D201364-W7 2011-07-05 10_23_33_Any CPU_Debug.trx
Test Settings: Default Test Settings
Waiting to publish...
Publishing results of test run D201364-W7$@D201364-W7 2011-07-05 10:23:33_Any CPU_Debug to http://mtlapp07:8080/tfs/DI_DEV...
..Publish completed successfully.
Final Property Values
Category = Galil
CommandLineArguments = /noisolation
Flavor =
MaxPriority = -1
MinPriority = -1
PathToResultsFilesRoot = C:\Builds\1\Galil Daily build\TestResults
Platform =
Publish = True
SearchPathRoot = C:\Builds\1\Galil Daily build\Binaries
TestConfigId = -1
TestConfigName =
TestContainers = System.Linq.OrderedEnumerable`2[System.String,System.String]
TestLists =
TestMetadata =
TestNames =
TestSettings =
ToolPath =
Version = -1
Final Property Values
Condition = False
Final Property Values
Condition = True
00:00
Handle MSTest Exception
MSTest.exe returned an exit code of 0 indicating that not all tests passed.
00:00
If testException is NOT TestFailureException
Initial Property Values
Condition = False
Final Property Values
Condition = False
编辑2.0:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Galil;
namespace TestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
Galil.Galil m_galil = new Galil.Galil();
m_galil.address = "COM4 19200";
string resp = m_galil.command("MTA=2.5;");
Assert.AreEqual(":", resp);
try
{
m_galil.address = "OFFLINE";
}
catch (Exception)
{
}
}
[TestMethod]
public void TestMethod2()
{
Galil.Galil m_galil = new Galil.Galil();
m_galil.address = "COM4 19200";
string resp = m_galil.command("MTA=2.0;");
Assert.AreEqual(":", resp);
try
{
m_galil.address = "OFFLINE";
}
catch (Exception)
{
}
}
}
}