unit-testing

How to test this simple controller / view?

I have a really simple action in a controller that simply returns a view which only contains html. public class TestController : Controller { public ActionResult Index() { return View(); } } How can I make sure that the view renders without an error? When I execute this: UsersController controller = new UsersContro...

Rhapsody TestConductor Experiences

I was wondering whether anybody out there is actively using Rhapsody TestConductor? Or has tried it for a while, but then decided to turn it down for a particular reason? If so, what are your experiences, in which field do you apply it, what are the shortcomings, or why did you turn it down? At the moment we're considering TestConductor...

Problem running tests under Netbeans

I am running some Junit tests and Netbeans behaves strangely giving the report in "Output" window: Testcase: warning(junit.framework.TestSuite$1): FAILED No tests found in uk.ac.cam.ch.wwmm.chemicaltagger.ChemistryPOSTaggerTest junit.framework.AssertionFailedError: No tests found in uk.ac.cam.ch.wwmm.chemicaltagger.ChemistryPOSTa...

Run a single test method with maven

I know you can run all the tests in a certain class using: mvn test -Dtest=classname But I want to run an individual method and -Dtest=classname.methodname doesn't seem to work. Thanks -Bill ...

How to fire "onload" event on document in IE

I am currently developing Unit Tests for a Javascript method that detects the readiness of the document. This code is already at framework level, so please avoid mentions of this being already implemented in jQuery or another library. I have successfully simulated the 'readystatechange' change event with the following code: var event; ...

NMock Problem with Lists

Hi, I have the following test using NMock which fails. It used to work when the result from the service call was passed to the view but it now fails since the results are converted to dto's. I think this might mean I need to create a custom matcher but I am not sure. Does anyone have any ideas? Error Message: Test method Dgc.Cpo.RM.U...

Best place to store reference directories for unit tests in boost?

I'm trying to write a library which unzips a zip file contents to an existing directory, replacing the content of only the folders which exist in the zip file. In order to do this I am employing the use of the Boost Unit Testing framework. Before each test I wish make a copy of an existing directory, the copy of which will serve as the...

How do I stop the Development Server starting during Unit Testing?

I have a Visual Studio 2008 solution that contains around 30 projects. Some of these are web services / WCF services / ASP.NET MVC applications. When I run all unit tests (Ctr+R, A) it insists on spinning up all the Development Servers for these various projects. This means that it takes far too long to run the tests and, actually, none...

HelloWorld ASP.NET 2.0 unit test fails in VS2008

Hello, When trying to run a super basic unit test in VS2008 ASP.NET 2.0, it fails: Details: At first a simple HelloWorld() test in this ASP.NET web application project works, then I add something more real-world to the project, like an SqlDataSource and try to test that, which fails. Then I remove everything except the HelloWorld() ...

Boost Unit Testing and Visual Studio 2005/Visual C++ and the BOOST_AUTO_TEST_SUITE(stringtest) namespace?

I'm reading this article on the Boost Unit Testing Framework. However I'm having a bit of trouble with the first example, my guess is that they left something out (something that would be obvious to hardcore C++ coders) as IBM often does in their articles. Another possibility is that my Visual Studio 2005 C++ compiler is just too old f...

OCMock with Core Data dynamic properties problem

I'm using OCMock to mock some Core Data objects. Previously, I had the properties implemented with Objective-C 1.0 style explicit accessors: // -- Old Core Data object header @interface MyItem : NSManagedObject {} - (NSString *) PDFName; - (void) setPDFName:(NSString *)pdfName; @end // -- implementation provides generated implementatio...

How do you maintain discipline when doing TDD?

When I get excited about a new feature I'm just about to implement or about a bug that I've just "understood", there is the urge to just jump into the code and get hacking. It takes some effort to stop myself from doing that and to write the corresponding test first. Later the test often turns out to be trivial 4-liner, but before writin...

Is unit testing always automated?

Can anyone provide an source that says that unit testing is not always done in an automated or programmatic way? I always assumed it meant testing code through code. I have a bet on this, so I need solid sources. ...

How do I unit test a controller method that has the [Authorize] attribute applied?

I've searched stackoverflow and googled four a couple of hours and still not found any solution for my "trivial" problem. If you write unit test for your filtered [Authorize] ActionResult, how do you solve the problem to fake that user is authenticated? I have a lot of ActionResult methods that are filtered with [Authorize] and I want ...

What is the Pattern for Unit Testing flow control

I have a method that checks some assumptions and either follows the happy path, or terminates along the unhappy paths. I've either designed it poorly, or I'm missing the method for testing that the control of the flow. if (this.officeInfo.OfficeClosed) { this.phoneCall.InformCallerThatOfficeIsClosedAndHangUp(); return; } if (!th...

How can I change the unit tests that are run for a particular build configuration?

We have a Visual Studio 2008 solution with a large number of projects in it. For the current product, only some of those projects are being used. We've created a build configuration for that product so we don't have to build every project in the solution. I want to be able to easily run all the unit tests that are relevant for this bu...

Why can't code inside unit tests find bundle resources?

Some code I am unit testing needs to load a resource file. It contains the following line: NSString *path = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"txt"]; In the app it runs just fine, but when run by the unit testing framework pathForResource: returns nil, meaning it could not locate foo.txt. I've made sure that foo.t...

how to generate a stream from a string ?

I need to write a unit test for a method that takes a stream which comes from a txt file, I would like to do do something like this: Stream s = GenerateStreamFromString("a,b \n c,d"); ...

How do I get ReSharper to ignore certain categories when running all tests?

I've got about 650 NUnit tests in my current solution in VS2008, but 40 of these are categorized either as "LongRunning" or "Integration". I do not want these to run every time I've done a change and run my test-suite (only when I specifically ask for it, and on the CI at set times). Setting this up with TestDriven.Net is a cinch: Tools...

distributing R package containing unit tests

so I decided I would put my few R functions into a package and I'm reading/learning Writing R Extension. it obviously complains about an amount of things I'm not doing right. after enough googling, I'm firing a few questions here, this one is about testing style: I am using RUnit and I like having tests as close possible to the code be...