mstest

How to Properly Test Controllers in ASP.net MVC that has database calls

烂漫一生 提交于 2019-11-30 14:12:58
问题 I am working on an ASP.net MVC 3.0 Application. I am using MSTest along with Moq for unit testing. I have written all the test methods for my controllers and ran those tests , which gave successful results. Now, I have a doubt whether I have properly made unit testing. Because, almost most of my controller actions contains database calls. I am not mocking them , I am mocking only Session and Request objects using Moq. Is it really necessary to mock database calls, since unit testing means

MSTest Test Context Exception Handling

无人久伴 提交于 2019-11-30 13:51:29
Is there a way that I can get to the exception that was handled by the MSTest framework using the TestContext or some other method on a base test class? If an unhandled exception occurs in one of my tests, I'd like to spin through all the items in the exception.Data dictionary and display them to the test result to help me figure out why the test failed (we usually add data to the exception to help us debug in the production env, so I'd like to do the same for testing). Note: I am not testing that an exception was SUPPOSED TO HAPPEN (I have other tests for that), I am testing a valid case, I

NUnit vs Visual Studio 2010's MSTest?

岁酱吖の 提交于 2019-11-30 12:38:11
问题 I realise that there are many older questions addressing the general question of NUnit v MSTest for versions of Visual Studio up to 2008 (such as this one). Microsoft have a history of getting things right in their 3rd version. For MSTest, that is VS2010. Have they done so with MSTest ? Would you use it in a new project in preference to NUnit? My specific concerns: speed running tests within CruiseControl.NET (either commandline or MSBuild task) code coverage reports from CC.NET can you run

MSTest - How to limit test result folders

非 Y 不嫁゛ 提交于 2019-11-30 11:15:55
Every time an MSTest runs it creates a new time stamped folder inside of TestResults . This can result in many files/folders that take up hard drive space. Is there a way to configure MSTest to overwrite the contents of the TestResults folder so that is only contains results from the most recent run? RB. You can limit the number of stored test-runs to 1, which should meet your requirements. MSDN have an article on how to achieve this: In Visual Studio, click Options on the Tools menu. The Options dialog box appears. Expand Test Tools or Web Performance Test Tools and click Test Execution Under

how does MSTest determine the order in which to run test methods?

纵然是瞬间 提交于 2019-11-30 11:06:37
edit: note, question 288805 is similar, however, I specifically am asking how does MSTest choose the default test order. Please see the rest of this question. Thank you Eilon for the link . I was looking at a legacy MSTest project. The tests were always running in the same order. The order was not alphabetic and was bouncing between methods in two *.cs TestMethod files. I did not change the physical order of the legacy code. I did for my convenience append "MSTest01" to the method name of the first test, "MSTest02" to the method name of the second test, et cetera. To my surprise, the execution

Global test initialize method for MSTest

烂漫一生 提交于 2019-11-30 10:42:57
问题 Quick question, how do I create a method that is run only once before all tests in the solution are run. 回答1: 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

How to Properly Test Controllers in ASP.net MVC that has database calls

巧了我就是萌 提交于 2019-11-30 09:48:14
I am working on an ASP.net MVC 3.0 Application. I am using MSTest along with Moq for unit testing. I have written all the test methods for my controllers and ran those tests , which gave successful results. Now, I have a doubt whether I have properly made unit testing. Because, almost most of my controller actions contains database calls. I am not mocking them , I am mocking only Session and Request objects using Moq. Is it really necessary to mock database calls, since unit testing means testing a single unit of code? I think unit testing controller with database calls violates above

SonarQube Test Coverage with MsTest

风格不统一 提交于 2019-11-30 09:11:20
问题 I have been trying to get SonarQube working with a simple dot net app. I have had some success getting it up and running but code coverage is not working. It looks like many other people have faced this issue when SonarQube discontinued support for many of the 'go to' coverage tool such as DotCover and OpenCover via Gallio Examples which I have followed are: Sonar Runner errors out during processing of .coveragexml file produced from Visual Studio's MSTest VS2013 CodeCoverage.exe runsettings

DataTestMethod and DataRow attributes in MSTEST

天大地大妈咪最大 提交于 2019-11-30 07:51:35
I have seen in a Microsoft video about Visual Studio update 2 regarding these attributes. However, I can't find any other information about them and can't get a project to build with them. Does anyone know anything about these attributes or how to get them working? [DataTestMethod] [DataRow("a", "b")] [DataRow(" ", "a")] public void TestMethod1(string value1, string value2) { Assert.AreEqual(value1 + value2, string.Concat(value1, value2)); } I know this is an old question, but there is now a good walkthrough published at https://blogs.msmvps.com/bsonnino/2017/03/18/parametrized-tests-with-ms

Is it possible to use the logical call context within a unit test in VS 2010?

此生再无相见时 提交于 2019-11-30 06:40:31
Is it possible to make this test not throw an exception? It appears that adding any non-GACed class into the logical call context causes an exception to be thrown in line 2 of the test. Test 'TestProject1.UnitTest1.TestMethod1' failed: Test method TestProject1.UnitTest1.TestMethod1 threw exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Type is not resolved for member 'TestProject1.Bar,TestProject1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. ---> System.Runtime.Serialization.SerializationException: Type is not resolved