【问题标题】:How does Microsoft Test Manager run automated Unit tests?Microsoft 测试管理器如何运行自动化单元测试?
【发布时间】:2014-04-29 16:46:27
【问题描述】:

我已将一些测试用例与项目中的单元测试相关联。该项目被构建并复制到共享上的放置位置。当我去运行这些测试时,由于 System.DllNotFoundExceptions 来自作为这些测试的一部分包含的非托管 DLL,我遇到了很多失败?

有人知道为什么会这样吗?我有一个实验室环境设置,并且测试(据说)在那台机器上运行。这些测试运行时的工作流程是什么? TestController 是将单元测试 DLL 复制到实验室环境中机器的本地某处,还是尝试直接从构建文件夹运行?

这是错误的堆栈跟踪。请注意,c:\Builds\ 不在测试机器上,这对我来说似乎很可疑。

Test method OutputProcessing.Integration.PanaceaOutputG1.ReactorCoreSimulationResults threw exception: 
System.DllNotFoundException: Unable to load DLL 'ge.gnf.cedar06.c.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Gnf.Cedar.NativeMethods.ATACHF(Int32& fileCode, String fileName, Int32& openMode, Int32[] stat)
Gnf.Cedar.ManagedMethods.Atachf(String fileName, FileAccess access, Int32[] stat)
Gnf.Cedar.Cypress.CedarFile.OpenCedarFile(String path, FileAccess access, FileSizeHint hint, AuditMode auditMode, ChainingOrderOption chainingOrder, Boolean createIfMissing)
Gnf.Cedar.Cypress.CedarFile..ctor(String path, FileMode mode, FileAccess access, FileSizeHint hint, AuditMode auditMode, ChainingOrderOption chainingOrder)
Gnf.Cedar.Cypress.CedarFile..ctor(String path, FileMode mode, FileAccess access)
GE.GNF.Acumen.Cedar.DataAccess.CedarRepository.GetCedarFile() in c:\Builds\11\ACUMEN\DEV Test Build\src\Acumen\Cedar\Cedar.DataAccess\CedarRepository.cs: line 67
GE.GNF.Acumen.Cedar.DataAccess.CedarRepository..ctor(String fullFilePath) in c:\Builds\11\ACUMEN\DEV Test Build\src\Acumen\Cedar\Cedar.DataAccess\CedarRepository.cs: line 40
GE.GNF.Acumen.Cedar.DataAccess.CedarRepository..ctor(String fullFilePath, String qualifier) in c:\Builds\11\ACUMEN\DEV Test Build\src\Acumen\Cedar\Cedar.DataAccess\CedarRepository.cs: line 43
OutputProcessing.Integration.PanaceaOutputG1.ReactorCoreSimulationResults() in c:\Builds\11\ACUMEN\DEV Test Build\src\Acumen\Auto Integration Tests\OutputProcessing.Integration\PanaceaOutputG1.cs: line 58

【问题讨论】:

    标签: microsoft-test-manager


    【解决方案1】:

    包含测试实现的 DLL 将被复制到测试机器。

    您可以激活 Test Agent 日志并在日志文件中检查哪些文件已部署。

    要激活这些日志:

    1. 转到 C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE 文件夹
      (这是 Test Agent 2012 的路径,如果您使用的是旧版本,路径略 不同)。
    2. 更改文件QTAgentService.exe.config(将EqtTraceLevel设置为“4”,CreateTraceListener设置为“yes”):
    <configuration>
     <system.diagnostics>
      <switches>
      <!-- You must use integral values for "value".
       Use 0 for off, 1 for error, 2 for warn, 3 for info, and 4 for verbose. -->
       <add name="EqtTraceLevel" value="4" />
      </switches>
     </system.diagnostics> 
     <appSettings>
      <add key="CreateTraceListener" value="yes"/>
     </appSettings>
    </configuration>
    

    重启Test Agent,你会发现在同一目录下创建了VSTTAgent.log文件。

    现在开始您的测试,然后检查此日志文件。您会找到类似这样的条目(只需搜索“复制远程文件”:

    I, 5856, 4, 2014/01/31, 09:50:58.283, <computer name>\QTAgentService.exe, Copying remote file: C:\Users\<tfs build user>\AppData\Local\VSEQT\QTController\<test run>\Deployment\<your DLL file> to: C:\Users\<local user>\AppData\Local\VSEQT\QTAgent\<test run>\<test configuration>\Deployment\<your DLL file>
    

    现在您可以检查是否已部署所有 DLL。

    注意: source 路径位于运行 Test Controller 的机器上,destination 路径位于测试机器上(Test Agent 正在运行)。

    据我所知,非托管 DLL 不会与“单元测试 DLL”一起部署,因此您必须确保它们会被部署。
    您可以使用测试设置

    【讨论】:

    • 您能否详细说明如何在测试设置中使用部署选项?当我在那里添加文件时,它使用我机器上的绝对路径。这在自动化环境中如何运作?
    • 您应该使用 UNC 路径。确保测试控制器可以访问此路径。
    • @Elena 是的,但是如果您尝试将其作为自动构建的一部分,那么您的放置位置总是会随着构建号的增加而变化。我遇到了同样的问题,但是测试尝试在运行时加载的 xml 数据文件。
    • @EJA 如果这些 xml 文件是测试项目的一部分,您可以使用 [DeploymentItem] 来部署它们。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-06
    相关资源
    最近更新 更多