mstest

In MSTest how to find the total number of tests to run in ClassInitialize or AssemblyInitialize?

喜夏-厌秋 提交于 2019-12-24 05:29:32
问题 Using MStest - I want to find the total number of test methods which are queued for run. How should I capture this value in ClassInitialize() or AssemblyInitialize() method. Only thing I get is TestContext which has no details of total number of tests. 回答1: I actually have an answer to this one, but you have to use Reflection to do it. This method gets all of the tests in the class and runs them. Each test starts with the string "TC" for test case. -sulu public async Task RunServiceTests() {

How to use multiple excel files as data source for unit test in C#?

蹲街弑〆低调 提交于 2019-12-24 05:27:31
问题 I am trying to make a unit test that have data source from multiple excel files, each excel file contains a test case for the same unit test. I would like to put all the excel files in one folder and let the unit test program to iterate through all the excel files. I have found several methods, like storing all the test cases in a XML file but this method is too tedious as I have to extract all the test cases from the excel files and put it into the same XML file. I hope to get an efficient

MSTest empty directory after test deleted

余生长醉 提交于 2019-12-24 05:17:05
问题 I have a unit test (using MSTest in VS2008 or VS2010) where I create a folder like this: [TestMethod] public void TestMethod1() { string newdir = Path.Combine(Directory.GetCurrentDirectory(), "WorkingRoot"); Directory.CreateDirectory(newdir); Assert.IsTrue(true); } During the test when I set a breakpoint at the assert, I see that the folder has been created in the specific run folder of MSTest. But when the test has been finished, the folder has been deleted. Why? 回答1: MsTest seems to delete

Convert MSTest code covarage results in to XML

僤鯓⒐⒋嵵緔 提交于 2019-12-24 00:07:32
问题 I am using this code to convert MSTest code covarage results to XML format , I added reference to Microsoft.VisualStudio.Coverage.Analysis.dll bu there is no class called CoverageInfoManager . I am using VS 2010. static void Main(string[] args) { String coveragepath = System.IO.Path.GetDirectoryName(args[0]); CoverageInfoManager.SymPath = coveragepath; CoverageInfoManager.ExePath = coveragepath; // Create a coverage info object from the file String coveragefile = System.IO.Path.GetFullPath

Questions on unit testing of private methods

浪尽此生 提交于 2019-12-23 20:09:47
问题 In MSTest, the [Shadowing] attribute helps you to unit test a private method from another assembly. Here is the related link : What is the Shadowing attribute that the VS uses when it generates unit tests? My questions are: Should private methods be unit tested separately? Is it a good (?) practice to change private method's accessor to internal just to make it available for unit testing in some other test project/assembly? (using InternalsVisibleTo ) If private methods get tested indirectly

MSTest code coverage

大兔子大兔子 提交于 2019-12-23 19:10:31
问题 I have a test project for a web service and, when I run tests in debug mode, everything works ok. However, when I just run tests, I get following error, for a referenced assembly that I try to obtain code coverage: Class Initialization method WebServiceTest.wstest.MyClassInitialize threw exception. System.IO.FileLoadException: System.IO.FileLoadException: Could not load file or assembly 'TestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=57f286581e1d278a' or one of its

How do I change Unit Test properties through the UI in the newer versions of VS?

别等时光非礼了梦想. 提交于 2019-12-23 18:22:02
问题 A few months ago, when I was reading about datasources in Unit Tests with MSTest, I stumbled on a few old posts, claiming that it was just a matter of going into properties and setting the datasource on the gui. This resulted in the attribute being added to the test method automatically with the required arguments. I was never able to select a unit test on the property grid though, and wondered what these people were talking about. Recently, I learned that this was a feature of the past, and

Using Resharper Unit Test Runner for MSTest via Gallio

不打扰是莪最后的温柔 提交于 2019-12-23 14:49:27
问题 I am attempting to get the Resharper test runner to recognize my MSTest unit tests via Gallio. I have the following installed: VSTS 2005 8.0.50727.762 Resharper 4.1 Gallio 3.0.0.285 I am also running Windows XP x64. The unit test options only shows NUnit as being available. I am thinking that I must have some versioning wrong. Can someone point me in the right direction? Am I barking up the wrong tree and this is only works in VS2k8? UPDATE: Well I updated Gallio to GallioBundle-3.0.4.385

MSTest no xml output on .NET Core RC2

醉酒当歌 提交于 2019-12-23 12:32:45
问题 I'm targeting dotnet-test-mstest": "1.0.1-preview on dotnet core rc2 in my test project. Edit: Okay. I'm targeting the the desktop .NET. But this should not make any difference. project.json { "version": "1.0.0-*", "testRunner": "mstest", "dependencies": { "Betgame": "1.0.0-*", "dotnet-test-mstest": "1.0.1-preview", "MSTest.TestAdapter": "1.0.0-preview", "MSTest.TestFramework": "1.0.0-preview", "NETStandard.Library": "1.5.0-rc2-24027" }, "frameworks": { "net461": { } } } output when running

MSTest hangs for seemingly no reason

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 09:13:06
问题 <TLDR> Running an MSTest test from the command line hangs without any errors or timeouts whilst "waiting for runs/agents". The reason might be that "there are no runs in the queue", but why this is so I have no idea, because the exact same test runs just fine on another machine. </TLDR> We've recently moved from evaluating TeamCity on a test machine, to installing it in our production environment. After migrating all of our build configurations we suddenly got problems with our MSTest tests: