mstest

Unit Test Description question

帅比萌擦擦* 提交于 2019-12-05 12:38:31
问题 There is a description entry for Unit Tests in Visual Studio. Is it possible to modify a test description after creation? 回答1: [TestMethod] [Microsoft.VisualStudio.TestTools.UnitTesting.Description("Test Case Description")] public void EnsureTestCaseValid() { } 回答2: The Description column in the Test View is readonly, but if you select a test and look in the Properties window, you'll find that the Description property is editable. This will add a [Description("string")] attribute to the test.

PrivateObject does not find property

百般思念 提交于 2019-12-05 12:20:34
I have a structure which looks basicly like this: abstract class A { protected string Identificator { get; set; } private void DoSomething() { // ... DoSomethingSpecific(); } protected abstract void DoSomethingSpecific(); } Because of the complexity I need do unit tests the DoSomething method to be sure it works allways in the same way. Thats why I created following stub. public class AStub : A { protected override void DoSomethingSpecific() { // nothing to do } } I use the PrivateObject class to access the methods and properties of class A be instantiating class AStub. This worked for a while

Your project does not reference “.NETFramework,Version=v4.6.2” framework. Add a reference to “.NETFramework,Version=v4.6.2” in the “TargetFrameworks”

风格不统一 提交于 2019-12-05 08:24:19
问题 I can't run my unit tests. I have the next error: Your project does not reference ".NETFramework,Version=v4.6.2" framework. Add a reference to ".NETFramework,Version=v4.6.2" in the "TargetFrameworks" property of your project file and then re-run NuGet restore. In app.config : <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/> </startup> In Project > Properties > Application > TargetFramework (.NET Framework 4.6.2) How can I fix it? 回答1: Please make the next steps

System.InvalidProgramException when executing unit tests in MSTest after Microsoft Security update MS13-004

穿精又带淫゛_ 提交于 2019-12-05 08:03:43
After applying the Microsoft Security update on the 8th of January 2013 http://technet.microsoft.com/en-us/security/bulletin/ms13-004 we have started to experience failures in our CI builds on our build servers and locally when running tests on our development boxes. We get a System.InvalidProgramException: Common Language Runtime detected an invalid program . This only happens when running tests using MSTest that make use of Castle Windsor DynamicProxy although I am not convinced DynamicProxy is at fault here. An example piece of code that would generate the exception is below. [TestMethod]

What's the life cycle of Unit Tests in C#

↘锁芯ラ 提交于 2019-12-05 06:43:51
What's the sequence of events in a full MSTest run of unit tests in C# inside Visual Studio (Ctrl+R, A)? Here's what I think so far: 1 - Runs [AssemblyInitialize] 2 - Randomly runs a [ClassInitialize] 3 - Runs the class [TestInitialize] 4 - Randomly runs a [TestMethod] from that class 5 - Runs the class [TestCleanup] Repeat 3 through 5 for each TestMethod in the class Repeat 2 through 5 for each test class 6 - Runs all classes [ClassCleanup] methods 7 - Runs [AssemblyCleanup] But I think VS might initialize multiple classes at once and then randomly run TestMethods. Should the tests be

Log4Net Multiple Projects

本秂侑毒 提交于 2019-12-05 05:06:58
I am using log4net in one of our solutions. The solution contains multiple projects, each a Unit-Test project. I am using the method described in this post to add logging to the various projects. I am using a rolling file appender to log all of the tests to a single log file that rolls over based on the size. Each of my projects log successfully to the log file, however, if I run tests from multiple projects (multiple test assemblies) , I only see logging from the first of the assemblies. For example, if I run tests from Project_A and Project_B , I only see logging statements from Project_A

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

天大地大妈咪最大 提交于 2019-12-05 04:51:21
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); } } driis The [ClassInitialize] decorated method should be static and take exactly one parameter of type TestContext : [ClassInitialize] public static void SetupAuth

MSTest is removing Test Results when VS2013 is running as Administrator

穿精又带淫゛_ 提交于 2019-12-05 03:45:36
I know that sounds strange but that is how it is) I'm using MSTest to run my unit tests. Using VS2013 + ReSharper 8.1 + some dll projects in C#. I'm calling some API functions, that is why I need VS to running as Administrator or those calls will fail. The problem is: For some reason folder TestResults is empty. While tests are running and not completed, I can see a new folder (User_Comp YYYY-mm-dd HH-MM-ss) created inside, with all test outputs, but once tests are completed this folder is deleted, so TestResults are empty. I've checked my project Options->Web Performance Test Tools->Test

SpecFlow: ClassInitialize and TestContext

独自空忆成欢 提交于 2019-12-05 03:32:59
first of all I'm new to SpecFlow. I have a feature file which I have / want to automate using MSTest to run as a functional test involving a fully set up server, data access ... For this purpose I have to configure the server with the data in the SpecFlow's 'Given' blocks and start it afterwards. I also have to copy some files to the test's output directory. In the non-SpecFlow functional tests I was using the ClassInitialize attribute to get the TestDeploymentDir from the TestContext; something like this: [ClassInitialize] public static void ClassSetup(TestContext context) {

Clean Up after Canceling tests

寵の児 提交于 2019-12-05 03:19:40
I'm currently running tests through visual studio. Before all the tests are run, I automatically create a set number of users with know credentials, and at the end of the run I delete those users. However, sometimes I need to cancel my tests midway. In these cases the test never gets the chance to clean up, this means that there is left over fake user info from the test run and may causes the next test run to crash (when it attempts to add user info into the DB). Is there anyway to force visual studio/mstest to run a clean up method even if the test is canceled? I know one option is to have