标签: mstest

在哪里可以找到Microsoft.VisualStudio.QualityTools.Resource.dll?

我正在为我们的C#项目设置新的Win7构建机器.我们不想在该计算机上安装Visual Studio.因此,我按照" 不使用Visual Studio运行mstest "的说明来设置我们的机器.

在第3步:

    Put Microsoft.VisualStudio.QualityTools.Resource.dll and
 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll in the GAC on the CIServer,
 because that is where they are on the DevMachine.
Run Code Online (Sandbox Code Playgroud)

在我的开发机器上(安装了Visual Studio 2008专业版),我在我的GAC(C:\ windows\assembly)中找到了它们,但我搜索了我的整个开发机器,却找不到 Microsoft.VisualStudio.QualityTools.Resource.dll

我的问题是:

  1. 哪里可以得到Microsoft.VisualStudio.QualityTools.Resource.dll
  2. 我可以从GAC复制上述文件吗?(我试过gacutil.exe,没有这样的复制选项.我试过了Control Panel->Administrative Tools,但我的XP机器只有Microsoft .Net Framework 1.1 Configuration上面两个组装没有出现.)?

谢谢,

.net c# mstest

1
推荐指数
1
解决办法
9068
查看次数

找不到MSTest.exe

可能重复:
mstest.exe位于何处?

我可以从Visual Studio 2010命令行工具运行它,但我在资源管理器中找不到它.我还需要安装其他东西吗?

我已经做了一些研究,它不是以下文章所说的那样......它不是任何地方.

mstest.exe在哪里?

我有Visual Studio 2010 Premium.

mstest visual-studio-2010

1
推荐指数
1
解决办法
2084
查看次数

让mstest在所需位置输出我的日志文件

我有测试运行在mstest,一切正常,它给了我一个日志文件.但是日志文件在项目的TestResults文件夹中输出.有没有我可以在mstest中更改的设置,在更改时让我将日志文件输出到我想要的位置.

如果是他们请告诉我如何去做.

提前致谢

c# mstest

1
推荐指数
1
解决办法
3425
查看次数

MsTest与Task.ContinueWith()和Task.Wait()......?

我仍然在.NET 4.0中,我想知道这种模式在各种异步单元测试情况下是否能够很好地保持:

/// <summary>
/// Noaa weather test: should read remote XML.
/// </summary>
[TestMethod]
public void ShouldReadRemoteXml()
{
    var uri = new Uri("http://www.weather.gov/xml/current_obs/KLAX.xml");
    var wait = HttpVerbAsyncUtility.GetAsync(uri)
        .ContinueWith(
        t =>
        {
            Assert.IsFalse(t.IsFaulted, "An unexpected XML read error has occurred.");
            Assert.IsTrue(t.IsCompleted, "The expected XML read did not take place.");

            if(t.IsCompleted && !t.IsFaulted)
                FrameworkFileUtility.Write(t.Result, @"NoaaWeather.xml");
        })
        .Wait(TimeSpan.FromSeconds(7));

    Assert.IsTrue(wait, "The expected XML read did not take place within seven seconds.");
}
Run Code Online (Sandbox Code Playgroud)

这种Task.ContinueWith()...Task.Wait()模式会在现实世界中持续存在吗?我对正式考虑单元测试(特别是异步单元测试)比较新,所以请不要停留在基础知识上:)

.net c# mstest task-parallel-library

1
推荐指数
1
解决办法
1172
查看次数

Moq-如何为多个测试一次初始化测试对象

我试图以这样一种方式来构造我的单元测试:如果我更改了要测试的对象的构造函数,则不必更改很多测试。这是我现在设置的简化示例:

[TestMethod]
public void Test1()
{
    _mockedObject1.Setup(etc);
    _mockedObject2.Setup(etc);
    var service = new TestedService(_mockedObject1.Object, _mockedObject2.Object, ...,
        _mockedObject7.Object);

    //Act and Assert
}
Run Code Online (Sandbox Code Playgroud)

现在,我有20个单元测试以相同的方式安排。如果必须更改TestedService的构造函数,则必须进入所有20个测试并更改创建服务的行。我可以将这行代码放入TestInitialize或其他内容中,这样我只需要更改一次即可?我首先想到的是,我不能这样做,因为这样一来,服务将在.Setups之前创建。还有另一种方法可以解决这个问题吗?

c# unit-testing mstest moq

1
推荐指数
1
解决办法
1926
查看次数

如何保持断言失败数据

我正在使用VS2013/CodedUI,在我的[TestMethod]中我声明如下:

Assert.IsTrue(String.Equals(logo.GetModifiedBy(), "Vendor2"));
Run Code Online (Sandbox Code Playgroud)

这在我的测试用例中如预期的那样失败,但输出中的消息如下所示,有没有办法报告用于比较的数据?我搜索但没有找到太多

Message: Assert.IsTrue failed
Run Code Online (Sandbox Code Playgroud)

c# mstest coded-ui-tests

1
推荐指数
1
解决办法
202
查看次数

TFS Build 2013无法选择mstest

在我的tfs上,如果我选择默认模板(tfvstemplate.12.xaml).我不想为我的单元测试运行mstest,但我不能选择其他测试运行器

我已经安装了tfs 2013和visual studio ultimate 2013.

选择字段仅被禁用

tfs mstest

1
推荐指数
1
解决办法
595
查看次数

在shim类中调用原始方法

我想针对一些错误的网络行为测试存储库.我使用MS Fakes伪造了这个类,它看起来像这样:

ShimInputRepository
                .AllInstances
                .UpdateEngagementStringNullableOfInt64NullableOfInt32String = (xInst, xEngId, xTrimUri, xTargetVers, xComments) =>
                    {


                        if (xEngId != initializer.SeededEngagementsWithoutEmp[3].EngagementId)
                        {
                            return xInst.UpdateEngagement(xEngId, xTrimUri, xTargetVers, xComments); //Unfortunately, calls recursively same method (not the original one)
                        }
                        else
                        {
                            throw new Exception
                                    (
                                        "An error occurred while executing the command definition. See the inner exception for details.",
                                        new Exception
                                        (
                                            "A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)"
                                        )
                                    ); …
Run Code Online (Sandbox Code Playgroud)

c# mstest shim microsoft-fakes

1
推荐指数
1
解决办法
1144
查看次数

UnitTests - Moq - 如何从与 Setup() 中的参数匹配的 Moq 返回() 对象

我对 Moq 感到困惑,我不确定这里有什么问题。

我想测试依赖于 ILeadStorageService 的 LeadService,并且我想以这种方式配置 Moq - 返回与安装程序中传递的 GUID 匹配的对象。

问题出在 Moq Setup/Returns 行中,因为当我将依赖对象替换为其真实实例时 - 测试通过,但完全错误。我不想只测试 LeadService,而不是从属存储。

    public LeadService( IConfigurationDbContext configurationDbContext, 
                        ILeadStorageService leadStorageService,
                        ILeadDeliveryService deliveryService)
    {
        this.configurationDbContext = configurationDbContext;
        this.leadStorageService = leadStorageService;
        this.deliveryService = deliveryService;

    }
Run Code Online (Sandbox Code Playgroud)

测试方法

        public TestLeadResponse ProcessTestLead(TestLeadRequest request)
        {
        var response = new TestLeadResponse()
        {
            Status = TestLeadStatus.Ok
        };

        try
        {
            var lead = leadStorageService.Get(request.LeadId);
            if (lead == null)
            {
                throw new LeadNotFoundException(request.LeadId);
            }

            var buyerContract =
                configurationDbContext.BuyerContracts.SingleOrDefault(bc => bc.Id == request.BuyerContractId);
            if (buyerContract == …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing mstest moq

1
推荐指数
1
解决办法
2043
查看次数

C#当参数数量相等时,如何使用System.Reflection调用私有重载方法

我有一个叫做的课TicketManager.这个类有两个私有方法private void Validate(Ticket ticket)和一个重载private void Validate(TicketResponse ticketResponse).

当我使用BindingFlags没有指定时,Type[]我得到一个不明确的匹配异常.

以下代码是使用MSTest的单元测试.

//testing private validation method using reflection
    [TestMethod]
    [ExpectedException(typeof(TargetInvocationException))]
    public void Validate_TicketResponseIsInvalid_ReturnsValidationException()
    {
        //Arrange
        TicketManager ticketManager = new TicketManager(ticketRepository);
        Ticket t = new Ticket { AccountId = 1, Text = "How do I test a private method in C#?", TicketNumber = 5 };
        TicketResponse tr = new TicketResponse { Ticket = t, IsClientResponse = false, Date = DateTime.Now };

        //reflection
        MethodInfo methodInfo …
Run Code Online (Sandbox Code Playgroud)

c# reflection mstest

1
推荐指数
1
解决办法
54
查看次数