在TFS上运行功能测试 [英] Run functional tests on TFS

查看:184
本文介绍了在TFS上运行功能测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在TFS上编写了一个运行功能测试的任务。

I wrote a task of Run functional tests on TFS.

任务启动良好但无法找到测试目标执行文件。

The task started well but it could not find test target execute file.

我的脚本在TestInitialize []指定了测试目标。

My script specified test target at TestInitialize[].

例如

        //在运行每个测试之前使用testinitialize运行代码 

        [TestInitialize()]

        public void mytestinitialize()

        {

            //为此测试生成代码,选择"生成用于编码ui测试的代码"。从快捷菜单中选择一个菜单项。

            string filepath =" .. \\\\\\..\\CodedUI Sample\\\\\\Debug \\CodedUI Sample.exe" ;;

            if(File.Exists(filepath))

            {

                testTarget = Process.Start(filepath);

            }

        //use testinitialize to run code before running each test 
        [TestInitialize()]
        public void mytestinitialize()
        {
            // to generate code for this test, select "generate code for coded ui test" from the shortcut menu and select one of the menu items.
            string filepath = "..\\..\\..\\CodedUI Sample\\bin\\Debug\\CodedUI Sample.exe";
            if (File.Exists(filepath))
            {
                testTarget = Process.Start(filepath);
            }

...

这在Visual Studio中效果很好。

This works well in Visual Studio.

我检查了工作目录它在AppData下。例如"C:\ Users \< Account> \ AppData \ Local \Temp \ TestResults _...."

I checked the working directory and it was under AppData. For example "C:\Users\<Account>\AppData\Local\Temp\TestResults_...."

似乎路径环境在Visual Studio中运行时以及从TFS任务开始时已更改,并且无法解析相对路径。

It seems that the path environment has changed when running in Visual Studio and when starting with TFS task, and the relative path can not be resolved.

如何编写测试代码或配置?

How can I write test codes or the configuration ?

推荐答案

Hi munyamunya,

Hi munyamunya,

感谢您在此发帖。

这在本地计算机上工作,这是因为CodedUI Sample.exe在相对路径下生成
(" .. \\..\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\Debug \\CodedUI Sample.exe ")。但它在TFS中找不到,因此如果在相对路径下有CodeUI Sample.exe,则需要在测试放置位置
检查。测试丢弃位置在运行功能测试中定义。

This works in your local machine, that's because the CodedUI Sample.exe generated under the relative path ("..\\..\\..\\CodedUI Sample\\bin\\Debug\\CodedUI Sample.exe"). But it can't find in TFS, so you need to check under the Test Drop Location, if there's an CodeUI Sample.exe under the relative path. The Test Drop Location is defined in your Run Functional Tests.

在您的方案中,似乎CodedUI示例是您解决方案下的另一个项目。

In your scenario, it seems that the CodedUI Sample is another project under your solution.

如果是这样,当您在TFS中执行此操作时,您需要确保同时检查CodedUI示例和您的测试项目  TFS。

If so, when you do this in TFS, you need to make sure both the CodedUI Sample and your test project are checked into TFS.

在TFS构建中,您还需要确保这两个项目映射到您的构建定义中。

And in TFS build, you also need to make sure these 2 projects is mapped in your build definition.

此外,您需要在构建定义中构建 2个项目。如果他们在相同的解决方案下,您只需要构建整个解决方案。

In addition, you need to build both the 2 projects in your build definiton. If they're under the same solution and you just need to build the whole solution.

最后,确保整个构建工件已发布
到您的Test Drop Location 发布构建工件步骤。

Finally, make sure that the whole build artifacts are published to your Test Drop Location in the Publish Build Artifacts step.

最好的问候


这篇关于在TFS上运行功能测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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