可以将F#项目用作编码测试的主要项目/主机吗?

时间:2016-08-04 12:54:08

标签: f# coded-ui-tests

我真的不想添加一个只为我的C#编码的UI测试项目才能调用的F#项目。我宁愿用F#来做整件事。

通过添加subtype Guid或只是正确设置program.fs,可以使用F#项目主机(如果UIMap.uitest文件不起作用,则无关紧要)a { {3}}并将其显示在VS2015测试资源管理器中?

1 个答案:

答案 0 :(得分:1)

是。我创建了一个标准的新F#库并添加了以下参考:

<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
  <Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Windows.Forms" />

这个Library1.fs文件:

namespace CodedUITestProject1

open System
open System.Collections.Generic
open System.Text.RegularExpressions
open System.Windows.Input
open System.Windows.Forms
open System.Drawing
open Microsoft.VisualStudio.TestTools.UITesting
open Microsoft.VisualStudio.TestTools.UnitTesting
open Microsoft.VisualStudio.TestTools.UITest.Extension

    [<CodedUITest>]
    type CodedUITest1 () =
        [<TestMethod>]
        member this.CodedUITestMethod1() =
            Assert.AreEqual(true, true)
            ()

        [<DefaultValue(false)>]
        val mutable testContext: TestContext

它对我有用:Test Explorer working