mstest

Mocking SqlConnection, SqlCommand and SqlReader in C# using MsTest

99封情书 提交于 2020-07-22 18:31:55
问题 I came across this answer and I'm interested in implementing the second answer using Fake. Here's another one. I'm not really understanding all the concepts there and I'm still reading and understanding documentation, can someone help using my code, where I'm trying to access list of customers on how to use Fake/Shim/Stub/Mock here? You may rewrite FindAll method too just in case if it's to be refactored to accept dependencies. Editing after discussion public class Data { private Func

Is it possible to run code after all tests finish executing in MStest

两盒软妹~` 提交于 2020-06-09 11:57:25
问题 I am writing coded ui tests and I have the application open if it is not already open. Then if one of them fails I close the application the thing is I have multiple tests in multiple projects is there a way to close the application after all of the tests are done executing? Is there maybe something in the testSettings file? If this helps at all, all of my test classes derive from one codeduiTestBase which is how I set up the settings I do have. I do not want to have to open and close the

Ignore IgnoreAttribute

做~自己de王妃 提交于 2020-05-09 18:15:50
问题 We have MSTest tests which automatically run in hourly production. One of these tests is marked with [Ignore] attribute because it is not yet ready to run it in our production environment. Now I want to start that test (only) on my local environment because my local environment is ready for that test. I try to run that test by clicking on ReSharper's icon on the left side of test code or by clicking Run Selected Tests icon in Unit Test Sessions window and nothing happens. I fix it currently

[UWP] 如何做 简单的UnitTest with Stub(基于微软原生的MSTest + SimpleStub)

不羁岁月 提交于 2020-04-19 04:27:06
近期应项目需要,笔者疯狂学习UWP项目测试的知识,确实学习到了不少关于测试方面的知识,等有时间会好好地记录下测试的学习成果。OK,回到主题,在笔者做项目测试的过程中把自己遇到的坑都简单的记录了下来,并且写了个关于测试的Demo, 传送门 。下面简单地笔者的初入测试门槛的经验! 首先上 环境 : Windows 10 OS Windows 10 SDK 10.0.15860 Visual Studio 2017 MSTest Framework 1.2.0 Etg.SimpleStubs 2.4.6 使用到的测试框架:MSTest 提供的 UnitTestFramework + 微软 Microsoft BigPark Studios 团队开发的 SimpleStub Mock框架。 处于笔者的水平限制,笔者先后尝试了 NUnit 、 XUnit 等多款测试框架但是效果并不是太好,其中 NUnit 似乎对 UnitTestProject (单元测试应用)并不太友好(多半是笔者水平的问题,如果有Dalao能教下我NUnit与UWP的集成请私信),网上的dalao们使用 XUnit 多数是基于 ClassLibrary 的项目,而笔者尝试的时候发现系统无法直接调用 ClassLibrary 所书写的测试 ,需要加载 Runner ,有些小麻烦,不过应该也是能用的。最终

How to write unit test for azure function (Httptrigger) with ILogger

混江龙づ霸主 提交于 2020-04-06 03:37:19
问题 Want to write unit test for HttpTrigger GET. Have method signature as follow: public static async Task<HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequestMessage request, ILogger log) here, ILogger is type of Microsoft.Extensions.Logging. How to write unit test case with this injection, Tried to create stub of ILogger using below stuff but this needs LoggerFactory . public class LoggerWriter : Microsoft.Extensions.Logging.Logger<ILogger> {

no test available..test through exe using build tools and test agent on VM

泪湿孤枕 提交于 2020-02-16 09:52:13
问题 I am trying to run an all included exe (created using Costura ) on a windows VM. As per an answer in this SO question , I have installed test agent and build tools and trying to run exe through this command C:\Users\..\Desktop>"C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" MyExeName.exe /Tests: MyTestName on VM , I start the agent and give above command but I am receiving error No test is available in C:

PrivateObject in Visual Studio

不羁岁月 提交于 2020-02-16 08:16:02
问题 I am using Visual Studio 2019 and in an MSTest Test Project (.NET Core) I am trying to use PrivateObject to test a protected method. For example, I'm trying to do something like following PrivateObject private= new PrivateObject(new Color()) But I get the following error PrivateObject could not be found are you missing a using directive or an assembly reference? I am also including using Microsoft.VisualStudio.TestTools.UnitTesting; which I thought would include PrivateObject . Any ideas? 回答1

PrivateObject in Visual Studio

前提是你 提交于 2020-02-16 08:15:27
问题 I am using Visual Studio 2019 and in an MSTest Test Project (.NET Core) I am trying to use PrivateObject to test a protected method. For example, I'm trying to do something like following PrivateObject private= new PrivateObject(new Color()) But I get the following error PrivateObject could not be found are you missing a using directive or an assembly reference? I am also including using Microsoft.VisualStudio.TestTools.UnitTesting; which I thought would include PrivateObject . Any ideas? 回答1

Specify MSTest parameters in MSBuild

北战南征 提交于 2020-01-25 04:46:25
问题 I'm trying to prevent certain (MSTest) unit tests from being run on our build server. I'd really like to just add a TestCategory, and then specify: /category:"!RequiresLoginCredentials" But I'm not sure how to indicate that in the msbuild project file. The relevant section of the build file currently has: <ItemGroup> <!-- TEST ARGUMENTS If the RunTest property is set to true then the following test arguments will be used to run tests. Tests can be run by specifying one or more test lists and