FAQ Database Discussion Community


mstest.exe is absent in VS2013 installation folder

c#,visual-studio-2013,mstest
Due to Microsoft's official cite it must be located at c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ Didn't find such topics in google or stackOverflow... In the same time I can run Unit tests from VS, but I need to run them from cmd... Have someone some ideas why its absent...

How to run tests from an external assembly

c#,.net,inheritance,testing,mstest
Here's what I'm trying to achieve. I'm providing some code through a nuget and want to also publish a second nuget containing tests to verify the service is working/deployed correctly. This test nuget would contain all the core tests to do so without any modification needed (except through config files)....

How can I cast/convert an anonymous type from HttpResponseMessage for unit testing?

unit-testing,c#-4.0,asp.net-web-api2,mstest,anonymous-types
I have been tasked with writing a unit test for the following Web API 2 action: public HttpResponseMessage Get() { IEnumerable<KeyValuePair<long, string>> things = _service.GetSomething(); return ActionContext.Request.CreateResponse(things.Select(x => new { Thing1 = x.Prop1.ToString(), Thing2 = x.Prop2 }).ToArray()); } I am testing the status code and that works fine, but I...

vstest.console.exe not generating trx file, TestResults empty

msbuild,mstest,xunit,vstest,visual-studio-test-runner
I am trying to run below command on my build server, c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "C:\UnitTest\MyTests.dll" /settings:"C:\UnitTest\output.runsettings" /UseVsixExtensions:"true" /InIsolation /Logger:"trx" <?xml version="1.0" encoding="UTF-8"?> <RunSettings> <RunConfiguration> <ResultsDirectory>.\TestResults</ResultsDirectory> </RunConfiguration> </RunSettings> It generates TestResults folder which...

Testing an asynchronous WCF service using MSTest

c#,.net,wcf,async-await,mstest
I've implemented a WCF service using the async\await method in C#. The service operation contract is as follows: [OperationContract] Task<ResponseMessage<ProcessMultipleTransactionsResponse>> ProcessMultipleTransactionsAsync(RequestMessage<ProcessMultipleTransactionsRequest> msgIn); The method signature for the implementation is: public async Task<ResponseMessage<ProcessMultipleTransactionsResponse>> ProcessMultipleTransactionsAsync(RequestMessage<ProcessMultipleTransactionsRequest> msgIn) I'm...

How do I Execute Code after a Test failed

c#,unit-testing,mstest,vs-unit-testing-framework
I am Creating Unit Tests for a Library. This Library Connects to a Datasource and then I am doing some testing Stuff afterwards the Datasource will be disconnected. If one of the Tests fails, the Method is Terminated and I dont get to execute the Disconnection Function. Here's a Sample...

Unit testing async database methods

c#,entity-framework,unit-testing,async-await,mstest
I have a Web API that I want to test using MS Test. I want to test one controller in particular. This is the init code: public class MyControllerTests { private static MyController controller; [AssemblyInitialize] public static void Initialize(TestContext context) { controller = new MyController(); IoC.Register(Component.For<IDbContextFactory>().ImplementedBy<MockDbContextFactory>()); // other config }...

XML Serializer throwing exception: “method not found”

.net,xml,xml-serialization,mstest
var txnSerializer = new TxnSerializer(); //generated serializer TextWriter writer = new StringWriter(); txnSerializer.Serialize(writer, response.ReturnValue); is throwing the following exception: System.InvalidOperationException was unhandled by user code HResult=-2146233079 Message=There was an error generating the XML document. Source=System.Xml StackTrace: at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) at...

Mstest test kills process after completion of test

c#,mstest
I have a report (.html) file which I open when all my tests have executed. I have written the following code for the same: [ClassCleanup] public void CleanUp() { var sUrl ="\\PerfReport\\PerformanceTestReport.html"; Process.Start(sUrl); } The issue is - when the test completes, the browser window is closed also. I don't...

Is there a non-static ClassInitialize alternative in MSTest?

c#,visual-studio-2012,mstest,selenium-chromedriver
I'm using Visual Studio 2012 test framework (I guess that's MSTest). I have some code that I need to run once and only once before the various testmethods run. ClassInitialize seemed perfect until I learned that it must be static. First, I have an instance variable for ChromeDriver: private ChromeDriver...

Test Fails when running MSTest on commandline but passes in VS2012

unit-testing,automated-tests,mstest
I have one test out of a suite of tests that fails when running MSTest on the commandline. However, the same suite of tests passes within VS2012 IDE. I verified that the same test project dll is being executed on both commandline and VS2012 IDE. I verified this by commenting...

Execute code on test failure

c#,mstest
I have a bunch of automated UI tests with Selenium and MSTest. When a test fails I need to take a screenshot of the headless browser so I can diagnose what went on. Currently I do this with a try catch throw but it needs repeating in every test. [TestMethod]...

VSTest.Console.Exe does not execute tests

visual-studio-2012,mstest,unit-testing,vstest
vstest.console.exe does not execute my tests. var testProcess = new Process { StartInfo = new ProcessStartInfo { FileName = @"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe", Arguments = _testDllPath, UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true } }; I receive the following output when executing the commandline: Microsoft (R)...

MSTest fails Unit Test that passes in VS 2013

c#,unit-testing,encoding,mstest
I've been setting up a Cake script (C# Make) in preparation of automating our unit testing. I have the script set up and it's running the unit tests as expected except for one quirk... One of the simpler tests is failing when MSTest attempts to execute it but it passes...

Using forms in tests

c#,winforms,mstest
I have an integration test that makes a form appear. It is not a coded UI test, it is just a test that happens to use a form. Lets not discuss now, that in general it is a good idea or not, it is in my case necessary. If everything...

How I can stub IDBconnection

unit-testing,mstest,stub,microsoft-fakes,shim
I am writting Unit Test for my database connection. I have following class Public class A { public IDbConnection _dbConnection; public A() { _dbConnection = new SqlConnection(connectionStringName); } public int ExecuteNoneQuery(CommandDefination command) { return _dbConnection.Execute(command); } } I want to test this class, how I can test with Microsoft Stub/Shim...

Test is failing with “Method not found” error

unit-testing,continuous-integration,mstest,biztalk,tfs2012
I have configured BizTalk UnitTest Project to run on every check into TFS, but test run is failing with the below error: Method not found: 'Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy Microsoft.VisualStudio.TestTools.TestManagement.Tmi.GetControllerProxy(Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, System.Object)'. Error details: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe /nologo /usestderr /searchpathroot:"C:\Builds\29\BizTalk\<proj>\Binaries"...