unit-testing

Should I unit test event handlers

I tend to veer towards the opinion that only public interfaces should be tested, thereby covering testing of private procedures. However, an interesting question arose yesterday - should one test event handlers? My gut instinct is that logic should be stored in self-contained procedures invoked by the handlers themselves, but this is sub...

Python Packages??

Ok, I think whatever I'm doing wrong, it's probably blindingly obvious, but I can't figure it out. I've read and re-read the tutorial section on packages and the only thing I can figure is that this won't work because I'm executing it directly. Here's the directory setup: eulerproject/ __init__.py euler1.py euler2.py ... euler...

Create a mock request that cffile action=upload will process

I'm writing an upload function for ColdFusion of Wheels and need to unit test it once it's finished. The problem I'm having though is that I have no idea on how to create a mock multi-part form post in ColdFusion that I can use in my unit tests. What I would like to be able to do is create the mock request simulating a file being upload...

Changing Database schemas & unit tests

Hello all,      Before we start I know a fair few people consider tests that hit the database not "unit tests". Maybe "integration tests" would be a better name. Either way developer tests that hit the database.      To enable unit-testing I have a developer local database which I clear and the populate with a know set of data at the st...

Generate test coverage information from pyunit unittests?

I have some pyunit unit tests for a simple command line programme I'm writing. Is it possible for me to generate test coverage numbers? I want to see what lines aren't being covered by my tests. ...

How do you use PHPUnit to test a function if that function is supposed to kill PHP?

Essentially I have a method of a class called killProgram, which is intended to send a hTTP redirect and then kill PHP. How am I supposed to test this? When I run phpunit it doesn't return anything for that test, and closes completely. Right now I'm considering having the killProgram function throw an exception which shouldn't get hand...

How do I get webrat / selenium to "wait for" the CSS of the page to load?

When I use webrat in selenium mode, visit returns quickly, as expected. No prob. I am trying to assert that my styles get applied correctly (by looking at background images on different elements). I am able to get this information via JS, but it seems like the stylesheets have not loaded and/or gotten applied during my test. I see that...

Unit Testing With Computer Owned States

I am writing a unit test for when my computer receives/makes a phone call. The methods being tested are the events that handle the incoming/outgoing call. If the caller is not an approved caller then the call is rejected. The code works fine, but I can't really find anything to test against for my unit test. The problem is that the a...

Rhino Mocks - Set a property if a method is called

Is there a way with Rhino Mocks to set a property of a Stub if a method is called. Something like this: (Fake Code in bold) callMonitor.Expect(x=>x.HangUp()).SetProperty(callMonitor.InACall = false); The HangUp method returns void and I can't really change that. But I want my stub to know that the call was hung up when HangUp is call...

Impersonate User for Silverlight Unit Test

I'm attempting to write some tests using the Silverlight Unit Test Framework (the unsupported, unofficial MS library Microsoft.Silverlight.Testing). I need to impersonate three different users when testing some functionality of our application. Our application is for internal use at our company, so the authenticated user may get differe...

How should I promote Perl warnings to fatal errors during development?

When running an applications test suite I want to promote all Perl compile and run-time warnings (eg the "Uninitialized variable" warning) to fatal errors so that I and the other developers investigate and fix the code generating the warning. But I only want to do this during development and CI testing. In production, the warnings should...

ASP.NET Unit Test DirectoryNotFoundException

I am trying to get a ASP.NET Unit Test running and I keep getting a DirectoryNotFoundException: Could not find part of the Path 'C:\inetpub\wwwroot\WebsiteName\GPS\web.config. The problem is the path to the GPS web.config is C:\inetpub\wwwroot\WebsiteName\website\GPS\web.config. I can't figure out how to set the path of this web.config...

General unit testing concepts/practices in JavaScript against different browsers?

I’ve been writing unit tests in strongly typed languages and I have a fair good understanding about it. When writing unit tests in JavaScript to verify if certain functions are working properly in certain browsers I am back to the manual testing. I have no understanding of how it works. Because JavaScript is meant to close the gap betwee...

Can I aim for TDD or BDD in my started project?

I have decided to give a try to TDD and BDD on my already started project, encouraged by answers to questions like this: http://stackoverflow.com/questions/294909/should-i-start-using-tdd-on-a-project-that-doesnt-use-it-already I am struggling to really start with it. My project (opensource, hosted in http://gitorious.org/rubots) is gam...

Spring: JUnit-Test: applicationContext is not loaded...

Hi all, I've got the following Test-class, but it doesn't matter what I set as "ContextConfiguration-locations" - it never set my UserService. And it doesn't throw any error when I set a non-existing file in the locations-property... what am I doing wrong? @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "cla...

Visual Studio: Code coverage not generated for signed assemblies

We are developing a system using c# in Visual Studio 2008. When I configure VS to instrument my dll's and run the tests, only the dll that is not signed gets instrumented (nice way to find that we forgot one). Is there a way to generate code coverage on signed dll's or do I have to un sign them, run the analysis and then sign them agai...

Unit test for a method that takes a HttpResponse object as a parameter. OutputStream is not available.

I am trying to create a unit test for a method that takes a HttpResponse object as a parameter. What the correct way of doing this? I hope you seasoned unit testers out there can help me. Additional information: I tried creating a fake HttpResponse object by passing in a StringWriter. StringBuilder sb = new StringBuilder(); Stri...

Unit Testing Flex/Flash Libraries in FlashBuilder

For a normal Flash/Flex application I would include my Unit Tests in my application project (perhaps in a tests source folder alongside my main src folder). I'd then have two application entry points: the app, and it's tests. How are people doing this for their Flex Library Projects? You know, the kind that produces a SWC file. As far a...

Recommended Tutorials and videos to learn nunit testing in short time

Can you Recommended Tutorials and videos to learn nunit testing in short time. I know that there are a lot of good books talking about unit testing, but i just want to learn it short and i will go more deep using these books later. So if you know some good videos or nice tutorials, please share. ...

Should I unit-test my view in MVP(or VM) or how to keep the code in the view to a minimum?

I use Model-View-Presentation Model in my application and I am wondering whether I need to create unit tests for the view. (I am on .net 2.0 WinForms) Now typically the view should be so simple that it should not be necessary to create unit tests for it. At least that's the idea I got from the goal of having the separation of View vs. ...