所有测试均通过,但TFS将构建标记为部分成功 [英] All tests pass but TFS marks the build as partially succeded

查看:85
本文介绍了所有测试均通过,但TFS将构建标记为部分成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前的项目涉及构建一个由.Net应用程序控制的机械化盒子.我们连接了许多硬件库,并确实建立了一个集成服务器,并连接了所有硬件以运行每晚回归测试.

Our current project involves building a robotized box controlled by a .Net application. We interface with quite a few hardware libraries and we did set up a integration server with all the hardware connected to it to run nightly regression tests.

不幸的是,并不是我们设置中的所有硬件库都能与TFS和MSTest很好地集成.

Unfortunately, not all hardware libraires in our setup integrates nicely with TFS and MSTest.

当我们运行构建并以一定的权限进行测试时,我们将具有以下两种行为之一:

When we run our build and tests with a certain librairy, we have either one of these 2 behaviors:

  • 所有测试均已通过 TFS,但构建显示为 部分成功.
  • TFS不显示任何测试运行,但日志显示所有通过的测试,构建都标记为部分成功.
  • All tests are martked as passed in TFS but the build is shown as partially succeeded.
  • TFS shows no test run, but the log shows that all tests passed, build is marked as partially succeeede.

查看日志,可以将测试发布到TFS服务器后看到这两行, 处理MSTest异常" "MSTest.exe返回了退出代码为0 ,表明并非所有测试都通过了"

Looking at the logs, we can see these 2 lines after the tests are published to the TFS server, "Handle MSTest Exception" "MSTest.exe returned an exit code of 0 indicating that not all tests passed"

真正让我感到困惑的是,从命令行使用mstest运行相同的测试不会显示此问题.此外,从命令行运行时,MsTest 在所有测试通过时返回0,在出现错误时返回1

What really puzzles me is that running the same tests with mstest from the command line does not display this problem. Futhermore, when running from the command line, MsTest returns 0 when all tests pass and 1 when there is an error

所以我的问题是:

  1. 成功/失败时适当的MSTest返回代码是什么
  2. 除了Visual Studio中的日志外,还有其他详细的loggin功能可用吗?
  3. 关于哪里看的任何线索?

其他信息:使用(或不使用)mstest中的"NoIsolation"标志时,我们确实注意到了差异.使用该标志时,特定测试将通过,但是其他测试将失败...我们仍在调查该标志.

Additional info: We did notice a difference when using (or not) the "NoIsolation" flag in mstest. The specific tests will pass when using that flag, however other tests will fail... We are still investigating that one.

谢谢

日志的相关部分: 30/30个测试已通过

The relevant portion of the log: 30/30 test(s) Passed

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)
        {
        }
    }
  }
}

推荐答案

成功/失败的相应MSTest返回代码是什么

退出代码1 =并非所有测试都通过

Exit code 1 = not all tests pass

示例:

C:\ Program Files \ MSBuild \ Microsoft \ VisualStudio \ TeamBuild \ Microsoft.TeamFoundation.Build.targets(1377,5,1377,5): 警告:MSTest.exe返回了退出 代码1表示并非全部 测试通过.

C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(1377,5,1377,5): warning : MSTest.exe returned an exit code of 1 indicating that not all tests passed.

所有测试均通过

示例:

正在等待发布...正在发布 试运行结果 Company_TFSBuild_SVC @ BUILD-DEV 2011-07-01 13:15:46_任何CPU_发布到 http://company-source:8080/ ...
..发布成功完成.

Waiting to publish... Publishing results of test run Company_TFSBuild_SVC@BUILD-DEV 2011-07-01 13:15:46_Any CPU_Release to http://company-source:8080/...
..Publish completed successfully.

除了Visual Studio中的日志外,还有其他详细的登录功能可用吗?

您可以通过以下网址获得更详细的日志:

You can get a more detailed log by going to:

菜单栏->工具->选项...-> 项目和解决方案-> MSBuild 项目构建输出的详细程度

Menu Bar -> Tools -> Options... -> Projects and Solutions -> MSBuild project build output verbosity

关于哪里看的线索?

需要查看您的日志文件.

Need to see your log file.

这篇关于所有测试均通过,但TFS将构建标记为部分成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆