I'm at a point where I'd like to start writing unit tests for my MVC application. I've already figured out how to unit test the controller and I can unit test my underlying business libraries without any problem. I'm coming unstuck on a couple of items though:
How do I unit test my views? That is, after a controller has returned the...
I am using some of the testing libraries from Sharp Architecture which make use of NUnit 2.5.0 while the rest of my project uses NUnit 2.5.1 so I placed an assembly redirect in my test project app config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding>
<dependentAssembly>
...
This relates somewhat to:
http://stackoverflow.com/questions/24993/invalidoperationexception-while-creating-wcf-web-service-instance/1711550#1711550
I have a .NET C# class library (DLL) that calls a WCF web service. It seems like any .exe that calls that .DLL must now have the web service configurations in its .EXE.config file.
So fo...
I've written a class and many unit test, but I did not make it thread safe. Now, I want to make the class thread safe, but to prove it and use TDD, I want to write some failing unit tests before I start refactoring.
Any good way to do this?
My first thought is just create a couple threads and make them all use the class in an unsafe w...
For example the Equals method. a should equal b and b should equal a. Would you say it is OK to check this in one test case using two asserts like the following:
[Test]
public void Equals_TwoEqualObjects_ReturnsTrue()
{
var a = new Something();
var b = new Something();
Assert.That(a.Equals(b), Is.True);
Assert.That(b.Eq...
I have worked with code which had NUnit test written. But, I have never worked with mocking frameworks. What are they? I understand dependency injection and how it helps to improve the testability. I mean all dependencies can be mocked while unit testing. But, then why do we need mocking frameworks? Can't we simply create mock objects an...
Hi,
Is there any way to produce visual results of NUnit tests from within TeamCity's "Tests" tab, currently my NAnt script outputs an .xml file of the results using the following task:
<nunit2 haltonfailure="false" failonerror="false" verbose="true">
<formatter type="Xml" extension=".xml" outputdir="${tests.output.dir}" usefile="true...
We have a set of services in .NET 3.5\C# and WCF.
The NUnit tests need the services to be running and listening for requests.
The services need an updated SQL database to be ready for connection.
Currently the [SetUp] section of the unit test does two tasks:
Execute the latest SQL scripts to build the database.
Utilize a
System.Diagn...
Is there a way to see the code coverage when using nUnit? I know there's such a feature in visual studio but can you use it with nUnit or only with the built-in vs unit tests?
...
I've got several unit tests written with NUnit that are calling selenium commands. I've got 2 win2k3 server boxes setup, one is running selenium grid hub along with 2 selenium rc's. The other box is running 5 selenium rc's. All of them are registered with the hub as running Firefox on Windows (to keep it simple). In my unit test setup me...
hi, I have a function which opens up the help file for the app. The function takes 3 arguments :
ShowHelp(appPath, 1,
@"heelp\help.doc")
The first argument is the start path.
The second argument is the no of
levels up the start path.
The third argument is the path of the help file
after going up n levels from the
start path.
...
I currently used a batch file which runs a project of mine which is simlar to the following:
nunit-gui.exe nunit.tests.csproj
Can it be setup to use two or more project files? I've tried adding quote marks and seperating the project names with commas and semi-colons but no luck.
Will I just have to create a master solution with all t...
I'm having a little bit of a dilemma. I have a very basic class with functions returning specific XPath query results.
Here is the code I'm currently using.
[TestFixture]
public class MarketAtAGlance_Test
{
private XmlDocument document;
private MarketAtAGlance marketAtAGlance;
[SetUp]
public void setUp()
{
thi...
I am using NHibernate against an Oracle database with the NHibernate.Driver.OracleDataClientDriver driver class. I have an integration test that pulls back expected data properly when executed through the IDE using TestDriven.net. However, when I run the unit test through the NUnit GUI or Console, NHibernate throws an exception saying ...
I'm dipping my toes in how to test multi-threaded stuff, but not quite sure how to get started. I'm sure I will figure more stuff out easier if I could just get stuff going, so I was wondering if someone could help me write an NUnit test case for this simple class:
class Worker
{
public event EventHandler<EventArgs> Done = (s, e) =>...
Hi, I cannot seem to return the result.ViewName for use in Nunit tests as it always returns string.empty. I have explicitly set the name of the view inside my controller and would expect the test to pick this up. I have had a hunt around and it seems that I should get the Viewname back if I set it explicitly. Any one got any ideas?
publ...
I'm writing some NUnit tests for database operations. Obviously, if Add() fails, then Get() will fail as well. However, it looks deceiving when both Add() and Get() fail because it looks like there's two problems instead of just one.
Is there a way to specify an 'order' for tests to run in, in that if the first test fails, the following...
I'm considering two possibilities:
include NUnit with the source code
of an open-source project - to make
it very easy for the potential contributors to
run automated tests right away. I feel it is important to promote the "tests-first" culture in this project (or at least make it clear to everyone that tests matter).
distribute the ...
Some of NUnit's Assert methods are overloaded to use ICollection but not ICollection<T> and thus you can't use them.
Is there anyway around this? Heck, am I doing something stupid?
I'm having to drop back to using Assert.AreEqual rather than specialised methods and its making my tests ugly.
Any advice?
Edit:
Thanks for the responses...
Say I have this test:
[Test]
public void SomeTest()
{
var message = new Thing("foobar");
Assert.That(thing.Created, Is.EqualTo(DateTime.Now));
}
This could for example fail the constructor of Thing took a bit of time. Is there some sort of NUnit construct that would allow me to specify that the Created time don't have to be ex...