mstest

If using LINQ For Queries, Do We Need to Unit-Test Sorting?

Hi Guys, I have the following two methods on an interface for my service layer: ICollection<T> FindAll<T>(Expression<Func<T, bool>> predicate) where T : Post; ICollection<T> FindAll<T,TKey>(Expression<Func<T, bool>> predicate, OrderingOptions<T,TKey> orderingOptions) where T : Post; They are extremely similar. The first one (basica...

VS2010: Problem with a test's Setup Script in VS2010 Test Settings

In the VS2010 Test Settings file, I've specified a .bat file that invokes a powershell script. Running the .bat file from a command prompt works just fine and the .bat returns in less than 5 secs. However, if I try to run a test, the run eventually reports a 'not executed' result and reports an error "The setup batch file on agent mach...

MSTest not being executed when run by Cruisecontrol schedule

Some background: Im trying to implement the integration of Cruisecontrol (2.8.4), MSBuild and MSTest on my current project (.Net 4.0 and VS 2010). I'm using MSBuild to build my solution and added a MSTest as AfterBuild Target into my .csproj files to run my unit tests: <Target Name="AfterBuild" DependsOnTargets="GetTestAssemblies" > <...

How to integrate MSTest And MSBuild results in Cruisecontrol (v2.8.4)

How do you integrate MSTest and MSBuild results into specifically CruiseControl 2.8.4. I've read documentation online, but it seems to be outdated and not in line with how the later versions of cruisecontrol work. Any suggestions? ...

Visual Studio Unit Test - Weird behaviour

Has anyone seen this very strange behaviour before? I've got a solution whith 70 unit tests. All of them pass on my dev machine. Whenever I commit my changes, our continuous integration process kicks in and the build box will eventually run the same 70 unit tests. There is only ONE test in the build box that fails all the time. The err...

How to log unit test entry and leave in MSTest

I'm using MSTest and I want to write log entry before test executes and after it finishes. Obviously I don't want to add custom logging code at the beginning and end of each test - it would only make the test unreadable and seemed like a lot of effort (I have > 500 tests) Using TestInitialize and TestCleanup seemed like the way to go b...

Visual Studio data-driven tests

Hi, I'm using a TextContext property to access the current row in an Excel file. The test is repeated for all rows. Is it possible to access all rows in a single step? Rows are related, hence for me one sheet should be a complete run. Edit: I add some code as requested: int result = this.TextContext.Rows[0]["GlobalResult"]; foreach(va...

Gallio: Cannot run tests because the MSTest executable was not found

I installed the newest Gallio release 3.2.603 on a box without Visual Studio that will be our CI server. The NAnt script successfully built the .Net 4.0 projects but when it tries to run MSTest tests the following error occurs. [gallio] Gallio NAnt Task - Version 3.2 build 601 [gallio] [error] Assembly XXXXXXXXXXXXXX [gallio] Cannot r...

MSTest -> Why Can't I Debug Using BreakPoints?

I setup breakpoints, then run "Run Tests" in Visual Studio. Why don't MSTest run to my breakpoints? ...

MSTest inside a Console Application

Hi I was trying to get some tests running inside a console application using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; // this doesn't work The error I'm getting is: The type or namespace name 'VisualStudio' does not exist in the namespace 'Mic...

IDE stopping at thrown AssertionException, rather than failing the test. (MSTestExtensions culprit?)

I am using NUnit asserts within a MSTest project like as follows (NOTE: This shouldn't matter see comments to Dave Falkner's answer): using Microsoft.VisualStudio.TestTools.UnitTesting; using MSTestExtensions; using Assert = NUnit.Framework.Assert; using Is = NUnit.Framework.Is; This has worked great in my unit tests, but in my integr...

Why do my tests fail with System.Security.VerificationException?

I'm in the process of migrating one of my projects from VS2008 to VS2010. Now that I converted all of my projects in the solution to .NET 4.0 (Client Profile) when I run the test harness, almost all tests fail with the following exception: System.Security.VerificationException: Operation could destabilize the runtime. I've been...

run tests from msbuild script

Is there a sample script that runs tests in a solution from msbuild script. I am using MSBuild 4.4 and visual studio 2010. Thanks. ...

How do I test an abstract class's protected abstract method?

I've been working on the best way to test an abstract class named TabsActionFilter. I've guranteed that classes that inherit from TabsActionFilter will have a method called GetCustomer. In practice this design seems to work well. Where I've had some issues is figuring out how to test the OnActionExecuted method of the base class. This m...

How to mock extension methods with Rhino Mock?

I have extended objects of type IDataReader with some extension methods that I needed. The problem is now when I try to mock the IDataReader, the extended method is not included in the mock so when the row Expect.Call(reader.ExtensionMethod()).Return(someValue) is reach the ExtensionMethod is executed which is not what I want! I want tha...

How to output log in MS Unit Testing Framework VS 2010

Hi, I am trying to log some information while the unit test is running in MS Unit Testing Framework VS 2010. I tried Trace.WriteLine, Console.WriteLine and Debug.WriteLine but I am not able to see the output in the output window. Any idea how to do it? Thanks in advance ...

Why is [AssemblyInitialize] and [AssemblyCleanup] being called twice in same test project assembly?

I though the whole purpose of these attributes was to run them only once per assembly. I have a simple class as follows: [TestClass] public class AssemblyIntegrationTestSetup { public AssemblyIntegrationTestSetup() { } public TestContext TestContext { get; set; } [AssemblyInitialize] public static void SetupIntegrationT...

ASP MVC - ConfigurationManager Cannot find Appsettings

Hey all.. I am using MS Test to test one of my controller's actions. This method uses the ConfigurationManger to read appSettigns from the web.config. For some reason ConfigurationMangager is not able to find the appsettings. In NUNIT I would just make sure to add a copy of the webconfig file to the test project so that it is available ...

What is the history of MSTest

A colleague of mine claims that Microsoft paid the developer of NUnit to develop MSTest. I have not been able to find any information that backs this claim up. Is this true? What is the history of MSTest? ...

How to parallelize a Data-Driven unit test in Visual Studio 2010?

I know regular ms-test unit tests can be parallelized on a multi-core machine (with caveats of course) by specifying parallelTestCount attribute in the .testresults file in the test solution. Like this, <Execution parallelTestCount="1"> <TestTypeSpecific /> <AgentRule name="Execution Agents"> </AgentRule> </Execution> Mo...