mstest

How to both package with msbuild and run tests on TFS 2010 using Continuous Integration

天涯浪子 提交于 2019-12-22 09:39:21
问题 I am using TFS2010 and MSBuild to integrate a windows azure cloud solution to the CI. To create the required 2 files for deployment I added in the "MSBuild Arguments" the /t:Publish Here is the configuration I use in TFS to build the packages: Problem is : if I remove all arguments the tests are built correctly but no azure package is built as seen on the build results: Tho if I put the parameters the package is there but the test are not run : Is there a way to have both ? 回答1: I had

TFS 2015 Build: Test results not being published

不打扰是莪最后的温柔 提交于 2019-12-22 08:46:41
问题 I'm having a really weird error when TFS 2015 executes an automated test step. The results are generated, but it seems TFS unable to find them. In the end, it just says that no results were found to publish (which is weird, because it even outputs the result full path) Check below the build logs for more info: 2015-12-16T15:44:29.5816976Z Executing the powershell script: C:\TfsBuildAgents\VsoBuildAgent\tasks\VSTest\1.0.22\VSTest.ps1 2015-12-16T15:44:29.7066995Z ##[debug]Calling Invoke-VSTest

Why is Private Accessor deprecated?

会有一股神秘感。 提交于 2019-12-22 08:37:52
问题 It used to be the number one reason for us to choose MSTest from others that we could access and test private methods. Now that Private accessors are deprecated in Visual Studio 2012. Does anyone know why Microsoft make such decision? Is it because it's not a good practice to test private methods? Also, if I still need to unit test my private methods, how could I do that in VS 2012 and later versions? 回答1: According to VS team article Generation of Private Accessors... this feature was

Why is a ClassInitialize decorated method making all my tests fail?

為{幸葍}努か 提交于 2019-12-22 04:58:23
问题 I understand, from MSDN, that ClassInitialize is to mark a method that will do setup code for all tests, once, before all tests run. When I include such a method in the abridged fixture below, all tests fail. As soon as I comment it out, they pass again. [TestClass] public class AuthenticationTests { [ClassInitialize] public void SetupAuth() { var x = 0; } [TestMethod] public void TestRegisterMemberInit() { Assert.IsTrue(true); } } 回答1: The [ClassInitialize] decorated method should be static

MSTest Shows Partial Code Coverage on Compound Boolean Expressions

此生再无相见时 提交于 2019-12-22 04:04:54
问题 From Microsoft's documentation, partially covered code is "...where some of the code blocks within the line were not executed." I'm pretty stumped on this one (simplified for brevity): Given this method: public List<string> CodeUnderTest() { var collection = new List<string> { "test1", "test2", "test3" }; return collection.Where(x => x.StartsWith("t") && x == "test2").ToList(); } And this test: [TestMethod] public void Test() { var result = new Class1().CodeUnderTest(); CollectionAssert

Couldn't run tests after updating TestFramework in NuGet

佐手、 提交于 2019-12-21 20:16:28
问题 An exception occurred while invoking executor 'executor://mstestadapter/v2': Constructor on type 'Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner' not found. 回答1: Exit Visual Studio. Delete %temp%\VisualStudioTestExplorerExtensions Restart Visual Studio and try again. That's all it was. 回答2: I had the same problem while running tests in the build server. I tried below things and it started working: updated my projects to point to latest MSTest.TestAdapter and

How to get test result status from MSTest?

旧巷老猫 提交于 2019-12-21 20:09:05
问题 In NUnit, I can get the test result from context.Result.State . If its NUnit.Framework.TestState.Success , then I know the test passed. In MSTest, how do I get that info? I saw context.Properties.Keys , but none of them speak of the status of the test result. 回答1: Use the TestContext.CurrentTestOutcome property in the TestCleanup method: [TestClass] public class UnitTest { private TestContext TestContext { get; set; } [TestCleanup] public void TestCleanup() { if (TestContext

Unit Testing WPF Application with siteoforigin pack Uri

拟墨画扇 提交于 2019-12-21 17:37:41
问题 I have some unit tests that I'm writing for a WPF application, and as much as I've tried to avoid it, I have some code under test that instantiates a View. As soon as the view is instantiated, all the markup extensions, styles, etc are evaluated. To resolve this I've created a dummy Application and registered any required resources when the test assembly is initialized: [TestClass] public class AssemblyInitialize { [AssemblyInitialize] public static void SetupTestAssembly(TestContext context)

Mstest name instead Data Row with Data-Driven testing

给你一囗甜甜゛ 提交于 2019-12-21 17:17:50
问题 I use MsTests and Data Driven approach for testing. (Excel is data storage for tests) tests result dont provide any information about tests data. For example: Result look as: testname (Data row 5). And it is not clear for me. How can i customise output test result? For example testname (Test data (word, number, or row named)) 回答1: I found only one solution: I have MyData.xlsx file with 1000 rows. Simple logic: "A" column = 1, "B" column = A*2+2. Rows 5,6,7 and 11,12,13 conteins zero for make

Organization of Unit Tests in Visual Studio

£可爱£侵袭症+ 提交于 2019-12-21 17:07:45
问题 I'm currently creating a paired unit test assembly for every assembly in my project, both are in the same folder. MyProject/MyProject.csproj MyProject.Test/MyProject.Test.csproj Looking at open source projects, I've seen some smaller project put all tests in one assembly, and other split it out like mine. I'm dealing with a large solution so it would be pretty crazy to put all tests in one project. I currently have msbuild logic to run tests on all *.Test.csproj files. If I had all my tests