【发布时间】:2011-09-28 20:04:38
【问题描述】:
我们当前的项目涉及构建一个由 .Net 应用程序控制的机器人化盒子。我们与很多硬件库进行交互,并且我们确实设置了一个集成服务器,所有硬件都连接到它以运行夜间回归测试。
遗憾的是,并非我们设置中的所有硬件库都能与 TFS 和 MSTest 完美集成。
当我们使用某个库运行构建和测试时,我们会出现以下两种行为之一:
- 所有测试都标记为通过 TFS,但构建显示为 部分成功。
- TFS 显示没有测试运行,但日志显示所有测试都通过了,构建被标记为部分成功。
查看日志,我们可以在测试发布到 TFS 服务器后看到这两行, “处理 MSTest 异常” "MSTest.exe 返回 退出代码 0,表示并非所有测试都通过了"
真正让我感到困惑的是,从命令行使用 mstest 运行相同的测试不会显示此问题。此外,从命令行运行时,MsTest 在所有测试通过时返回 0,在出现错误时返回 1
所以我的问题是:
- 关于成功/失败的适当 MSTest 返回码是什么
- Visual Studio 除了登录,还有其他详细的登录功能吗?
- 有什么线索可以看吗?
附加信息:我们确实注意到在 mstest 中使用(或不使用)“NoIsolation”标志时有所不同。使用该标志时,特定测试将通过,但其他测试将失败......我们仍在调查那个。
谢谢
编辑:日志的相关部分: 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)
{
}
}
}
}
【问题讨论】:
-
你能发布你的日志吗?