MSTest: No tests are run because no tests are loaded or the selected tests are disabled

Another one for the googlers – this one turned out to be my problem, and it’s embarrassingly boneheaded of me. Make sure that your test project is set to build in whatever solution configuration you’re using. If the test assembly isn’t being built, VS won’t be able to find any tests in the non-existent assembly, … Read more

Can’t read app.config in C# .NET Core unit test project with ConfigurationManager

Looking through the github issue’s comments, I found a work around that can go in the msbuild file… <Target Name=”CopyCustomContent” AfterTargets=”AfterBuild”> <Copy SourceFiles=”app.config” DestinationFiles=”$(OutDir)\testhost.dll.config” /> </Target> This makes it easier to verify existing tests under .NET Core before porting the configuration data over to json configuration files. Edit If running under Resharper, the previous answer … Read more

Visual Studio 2013 MSTest vs NUnit

MSTest hasn’t changed much since it was originally introduced, so those old comparison posts are still valid. Microsoft’s focus on ALM is mostly targeted at further tooling and server products, but the fundamental testing framework hasn’t changed much. It’s also worth noticing that MSTest and their entire ALM strategy is targeted at many different styles … Read more

MSTest Equivalent for NUnit’s Parameterized Tests?

For those using MSTest2, DataRow + DataTestMethod are available to do exactly this: [DataRow(Enum.Item1, “Name1”, 123)] [DataRow(Enum.Item2, “Name2”, 123)] [DataRow(Enum.Item3, “Name3”, 456)] [DataTestMethod] public void FooTest(EnumType item, string name, string number) { var response = ExecuteYourCode(item, name, number); Assert.AreEqual(item, response.item); } More about it here

Global test initialize method for MSTest

Create a public static method, decorated with the AssemblyInitialize attribute. The test framework will call this Setup method once per test run: [AssemblyInitialize] public static void MyTestInitialize(TestContext testContext) {} For TearDown its: [AssemblyCleanup] public static void TearDown() {} EDIT: Another very important detail: the class to which this method belongs must be decorated with [TestClass]. … Read more

Do MSTest deployment items only work when present in the project test settings file?

This post here helped me figure out what I needed to do WITHOUT having to manually add items to the .testsettings file. Step 1 – Enable the MS Test DeploymentItem attribute. First up, we need to turn on / enable the DeploymentItem attribute. Go to TEST -> EDIT TEST SETTINGS -> Current Active settings .. … Read more

MsTest ClassInitialize and Inheritance

Unfortunately you cannot achieve this that way because the ClassInitializeAttribute Class cannot be inherited. An inherited attribute can be used by the sub-classes of the classes that use it. Since the ClassInitializeAttribute cannot not be inherited, when the MyTest class is initialized the ClassInitialize method from the MyBaseTest class cannot be called. Try to solve … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)