mstest

AssemblyCleanup not firing

≡放荡痞女 提交于 2019-12-23 08:54:36
问题 I have some methods that are used for initializing and cleaning up a database that I'm using with my tests, but my methods with attributes AssemblyInitialize and AssemblyCleanup aren't firing. Any ideas? [TestInitialize] public void Init() { LoadData(); } [AssemblyInitialize] public void AssemblyInit() { } public void LoadData(string testDataFileName = "TestData.xml") { connectionString = ConfigurationManager.ConnectionStrings["NDbUnit"].ConnectionString; mySqlDatabase = new NDbUnit.Core

Data-driven unit testing - Problem with CSV encoding?

我的未来我决定 提交于 2019-12-23 08:35:40
问题 I have the following CSV file that is used in my data-driven unit test: File;expected Resources.resx;default Resources.de.resx;de AttachmentDetail.ascx.it.resx;it SomeOtherFile.rm-CH.resx;rm-CH "File" and "expected" are the header. But if I want to get the "File"-column in the code like TestContext.DataRow["File"].ToString(); I get the error System.ArgumentException: Column 'File' does not belong to table .. When I add the CSV file to an existing test-case over the test-method properties, it

Why can't Visual Studio find this nuget package's .props file?

隐身守侯 提交于 2019-12-23 08:26:30
问题 My team had to move to a new git instance. The guy that was goodly enough to migrate all the branches from our old server missed a feature branch I'm working in. My cheat-y solution was to copy the project I had added in my old feature branch to my desktop, clone the new repo, make a new feature branch, copy the .csproj and all the .cs files into the directory at the appropriate place, then add the existing project from the solution explorer. When I try to build, I get an error: This project

How to handle currentDomain.UnhandledException in MSTest

瘦欲@ 提交于 2019-12-23 07:46:17
问题 I tried to implement solution based on answer How to handle exceptions raised in other threads when unit testing?, but I still don't understand what to do in the handler. Let's suppose I have a test: [TestMethod] void Test() { new Thread(() => { throw new Exception(); }).Start(); } I have and global initialization of all tests: [AssemblyInitialize] public static void AssemblyInitialize(TestContext context) { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException +

MSTest data driven Test set DisplayName for Rows from DataSource

白昼怎懂夜的黑 提交于 2019-12-23 07:06:04
问题 How can I set the DisplayName of a Data Row in data driven tests, where the data source is a XML and the provider is Microsoft.VisualStudio.TestTools.DataSource.XML. XML: <?xml version="1.0" encoding="utf-8" ?> <environments> <environment><name>IE</name></environment> <environment><name>Chrome</name></environment> </environments> App Config: <!-- CONNECTION STRINGS SETTINGS --> <connectionStrings> <add name="IE_Chrome" connectionString="IE_Chrome.xml" providerName="Microsoft.VisualStudio

What is the best way of checking the matrix value in Unit test?

二次信任 提交于 2019-12-23 03:23:08
问题 What is the best way of checking the matrix value in Unit test? I have a method in my project, something like this: int[][] getMatrix() { int[][] ans = new int[1][]; ans[0] = new int[1]; ans[0][0] = 0; return ans; } I want to unit-test this class using visual studio standard testing engine, so I create a unit test, something like this: [TestMethod] public void Test() { var result = getMatrix(); int[][] correct = new int[1][]; correct[0] = new int[1]; correct[0] = 0; Assert.AreEqual(correct

Selenium geckodriver executes findElement 10 times slower than chromedriver (.Net)

喜欢而已 提交于 2019-12-23 02:58:11
问题 Sorry didn't find a similar question and maybe somebody can help. Due to additional requirements we have to test our project not only with Chrome but with Firefox as well. When we simply changed a test context to Firefox it turned out that all calls of findElement took 10 times more time than with Chrome. All tests are completely ruined. We tried to use different test machines but the results are the same. The project is on Core .Net. For testing we use MSTest V2, Firefox 63 (64 bit) and

DeploymentItem fails copying directories when there are multiple test projects per solution

只愿长相守 提交于 2019-12-22 18:15:22
问题 I have a number of test classes and methods that copy a particular directory like so: [TestClass, DeploymentItem("LanguageData", "LanguageData")] public class OcrTests { [TestMethod] public void Can_Capture_Field() { // some code that expects the LanguageData directory to be in the test results Out directory } // etc } [TestClass] public class OcrBuilderTests { [TestMethod, DeploymentItem("LanguageData", "LanguageData")] public void Can_Build_Specific_Ocr_Engine_Implementation() { // some

MSTest Command Line Settings

拥有回忆 提交于 2019-12-22 17:12:08
问题 We need to be able to pass a server address into MSTest command line for our testing suite that is invoke by TeamCity Continuous Integration (CI) software. Previously we created #if constants in C# unit tests, which made the change in MSBuild. Is there a better way? This way seems pretty hacky. Is there a way to create config files and pass arguments to be used within MSTest? 回答1: I use an app.config file in my test project to configure my tests. Source control contains the app.config used in

How can I disable code coverage / assembly instrumentation in Visual Studio 2012?

只愿长相守 提交于 2019-12-22 12:18:28
问题 I have a project upgraded from Visual Studio 2010 to 2012 and the .testrunconfig file was included in the upgrade process. I noticed that it was possible to click "Analyze code coverage" on any of the unit tests that I had run and it would correctly display the result. However, my test run configuration (originally from VS 2010) had code coverage disabled. After doing a bit of research I learned that the VS 2010 configuration files have been deprecated and replaced by .runsettings files. It