mstest

Log4Net Multiple Projects

偶尔善良 提交于 2019-12-07 01:40:21
问题 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

MSTest and NHibernate

时光毁灭记忆、已成空白 提交于 2019-12-07 01:33:56
问题 Does anyone have any experience getting MSTest to copy hibernate.cfg.xml properly to the output directory? All my MSTests fail with a cannot find hibernate.cfg.xml error (I have it set to Copy Always), but my MBUnit tests pass. 回答1: You can try adding the DeploymentItemAttribute to one of your tests, or edit your .testrunconfig file and add the file to the Deployment list. 回答2: Edit localtestrun.testrunconfig (in your solution items folder). Select the deployment option and add the hibernate

Clean Up after Canceling tests

纵然是瞬间 提交于 2019-12-07 00:52:12
问题 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

SpecFlow: ClassInitialize and TestContext

江枫思渺然 提交于 2019-12-06 22:30:49
问题 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;

MSTest is removing Test Results when VS2013 is running as Administrator

谁都会走 提交于 2019-12-06 21:07: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

How to run ClassCleanup (MSTest) after each class with test?

半腔热情 提交于 2019-12-06 19:55:10
问题 I have several classes with tests suites. Each test class starts from ClassInitialize and finishes by ClassCleanup. My problem is that ClassCleanup isn't called at the end of each class, it's called only after all tests in three classes. Can I fix this issue? Thanks! [ClassInitialize] public static void SetUpBrowser(TestContext context) { pageObjectBase.SetBrowser("chrome"); pagesManager.GetPageObjectBase(); } [TestMethod] public void FindCriticalBug() { bla-bla-bla(); } [ClassCleanup] public

How to run a single test case from MSTEST

与世无争的帅哥 提交于 2019-12-06 19:00:23
问题 I am using MStest to run a single test case but could not find a correct command I tried: 1) mstest.exe /testcontainer:testproject.dll /test:MethodTest1 This run all the test case starting from name MethodTest1. I have other test name Like MethodTest100, MethodTest101 2) mstest.exe /testcontainer:testproject.dll /test:MethodTest1 /unique This needs to pass Test Namespace name and Test Class name. It works when i execute following but i have only access to Test Method not to class or namepsace

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

非 Y 不嫁゛ 提交于 2019-12-06 14:41:25
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.Length, result.Length); for (int i = 0; i < correct.Length; ++i) { CollectionAssert.AreEqual(correct[i],

(MSTest) Extending ExpectedExceptionBaseAttribute hides test failure explanation

梦想的初衷 提交于 2019-12-06 12:06:05
When running this test: [TestMethod] [ExpectedException(typeof(SpecialException))] public void Test1() { throw new NotImplementedException(); } Visual Studio tells me why it fails: Test method [...].Test1 threw exception System.NotImplementedException, but exception [...].SpecialException was expected. Exception message: System.NotImplementedException: The method or operation is not implemented. But when I try to extend ExpectedExceptionBaseAttribute (to expect for error code in SpecialException ) like that: [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]

MSTest Command Line Settings

冷暖自知 提交于 2019-12-06 11:35:45
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? I use an app.config file in my test project to configure my tests. Source control contains the app.config used in TeamCity to run the tests. On compilation the app.config is copied to the bin folder and renamed to