Xunit.Runners.UI在VS2015中未发现Xunit测试

时间:2018-08-09 14:14:32

标签: android xamarin xunit

基于xUnit的普及,我确定对此有一个简单的解释,但是我没有尝试的想法。我遵循了Greg Shackles(https://gregshackles.com/testing-xamarin-apps-getting-started-with-xunit/)的“入门”一文,当我使用Console Runner时,一切都会按预期进行。当我创建Android项目,合并RunnerActivity并添加测试程序集时,该应用程序以正确的UI运行,但“测试程序集”下未显示任何内容。当我选择“全部运行”时,它会在输出窗口中写入运行0个测试,0个失败等...

我正在使用Visual Studio Pro 2015(版本14.0.25431.01更新3),Xunit 2.4,Xunit.runner.devices 2.3.3。我已经在KitKat设备和牛轧糖上进行了测试。

以下是我的测试课:

public class Class1
{
    [Fact]
    public void TestMethod_1()
    {
        Assert.Equal(2, 2);
    }

    [Fact]
    public void TestMethod_2()
    {
        Assert.Equal(2, 3);
    }
}

以下是我的MainActivity.cs:

[Activity(Label = "xUnit Android Runner", MainLauncher = true, Theme = "@android:style/Theme.Material.Light")]
public class MainActivity : RunnerActivity
{

    protected override void OnCreate(Bundle bundle)
    {
        // tests can be inside the main assembly
        AddTestAssembly(Assembly.GetExecutingAssembly());

        //AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly);
        // or in any reference assemblies           

        AddTestAssembly(typeof(Class1).Assembly);
        // or in any assembly that you load (since JIT is available)

        // you cannot add more assemblies once calling base
        base.OnCreate(bundle);
    }
}

任何帮助将不胜感激。谢谢。

0 个答案:

没有答案
相关问题