一般来说,我对C#和MSTest有点陌生,我尝试使用DynamicData属性进行参数化的单元测试--在运行时,这些参数似乎是在这里交换的,这是我测试的片段:
[TestClass]
public class SampleTest
{
private TestContext testContextInstance;
public TestContext TestContext
{
get { return testContextInstance; }
set {
我使用Unit Test Explorer和Unit Test Sessions来运行我的测试,突然得到下面的错误。
在Test -> Test explorer中运行时,测试根本不会运行,我看不到任何错误。
在这两种情况下,Output窗口中都没有任何内容。我重新安装了R#,清除了VS缓存(在%USERPROFILE%\AppData\Local\Microsoft中),重启了windows,重启了VS。
2019.10.25 14:54:08.058 ERROR Remote: An exception occurred while invoking executor '
我正在使用VS2015,并用MSTest编写测试。例如,在数据驱动测试中,MSTest似乎不会运行所有行,这是一个示例测试:
//there is a XML datafile that has 1000 "rows", 1 to 1000
int x = Int32.Parse((string)TestContext.DataRow["Payload"]);
if (x == 999)
throw new Exception();
当我调试测试时,它正确地在999处失败。但是,当我运行测试(而不是调试)时,测试结果显示(大多数情况下)测试已通过。测试的
我使用MSTest创建了Spring。在这个测试中,我使用。
[TestClass]
public class Test : AbstractDependencyInjectionSpringContextTests
{
[TestMethod]
public void Test()
{
}
protected override string[] ConfigLocations
{
get
{
return new string[] { "~/Configuration/sprin
我正在使用MsTest V2 framewrok进行测试。我有测试自动化框架(TAF)项目和带有测试的项目。测试项目继承自TAF,只包含测试。在TAF中,我有一个包含方法的类,这些方法应该在所有测试之前运行,但它根本不起作用。顺便说一下,BeforeTest方法工作得很好。
public class TestBase
{
[AssemblyInitialize]
public static void BeforeClass(TestContext tc)
{
Console.WriteLine("Before all tests");
使用MSTest,我需要从[TestInitialize]方法中获取当前测试的名称。您可以从TestContext.TestName属性获得此信息。
在传递给[ClassInitialize]方法的静态[ClassInitialize]和声明为公共属性(并由测试运行程序设置)之间,我发现了一个意想不到的行为差异。
考虑以下代码:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TestContext.Tests
{
[TestClass]
public class Unit