unit-testing

Write unit tests for restish in Python

Hi, I'm writing a RESTful API in Python using the restish framework. I would like to write some unit tests (using the unittest package, for example), that will make different requests to my application and validate the results. The unit tests should be able to run as-is, without needing to start a separate web-server process. How do I...

What's a unit test?

Possible Duplicates: What is unit testing and how do you do it? What is unit testing? I recognize that to 95% of you, this is a very WTF question. So. What's a unit test? I understand that essentially you're attempting to isolate atomic functionality but how do you test for that? When is it necessary? When is it ridiculous? C...

Unit testing for compiler errors

How do you test for wanted raised compiler errors in unit testing? Consider the code: class ErrorTest { OtherClass& read_write() { return other; } const OtherClass& read_only() const { return other; } private: OtherClass other; }; How can I test for read_only() assignment? It's really imp...

Unit testing with multiple collaborators

Today I ran into a very difficult TDD problem. I need to interact with a server through HTTP POSTs. I found the the Apache Commons HttpClient, which does what I need. However, I end up with a bunch of collaborating objects from Apache Commons: public void postMessage(String url, String message) throws Exception { PostMethod post =...

How can i get OCMock to let me stub a category method on a UIKit class?

I'm trying to mock a UITabBarController in my app's tests. I have a category method on that class defined elsewhere in another file that gets imported along with ocmock in my test class. what i'm trying to so is this: - (void) setUp { id mockTabController = [OCMockObject mockForClass:[UITabBarController class]]; [[[mockTabCont...

Is This a C++ Unit Test?

Hi, I am trying to formalize my programming practices in preparation to do it professionally (I have been doing it as a hobby for 18 years). Unfortunately they didn’t really teach us useful stuff in school, so I am trying to learn these things on my own. One aspect that I am trying to learn is unit-testing. I have read various things a...

NUnit test runner GUI that easy can load multiple DLLs

We have loads of DLLs with tests. I'm looking for a test runner (GUI) that either allows me to load all DLLs in a folder or that can load all tests from Visual Studio solution files. Ideas? (I would like to use it as a complement rather than a replacement to our nightly builds (that runs all tests)). ...

Are there any good online tutorials to TDD for an experienced programmer who is new to testing?

I'm working with a Python development team who is experienced with programming in Python, but is just now trying to pick up TDD. Since I have some experience working with TDD myself, I've been asked to give a presentation on it. Mainly, I'm just wanting to see articles on this so that I can see how other people are teaching TDD and get...

WatiN: Print Dialog

Hello, I have a screen that pops up on load with a print dialog using javascript. I've just started using WatiN to test my application. This screen is the last step of the test. What happens is sometimes WatiN closes IE before the dialog appears, sometimes it doesn't and the window hangs around. I have ie.Close() in the test TearDow...

How do I unit test this PL/SQL procedure? (using utplsql)

Package is very very basic. Loops through a cursor, and updates 2 values where the record_ids are equal. What's an appropriate unit test for this sort of procedure? I'm going to add some skeleton code because the answers so far, while good, tie to the crux of my issue here: What do I test? PROCEDURE set_shift_times_to_null( RETVAL OUT...

Unit Testing and Stored Procedures

How do you unit test your code that utilizes stored procedure calls? In my applications, I use a lot of unit testing (NUnit). For my DAL, I use the DevExpress XPO ORM. One benefit of XPO is that it lets you use in-memory data storage. This allows me to set up test data in my test fixtures without having an external dependency on a da...

Testdriven.Net And NUnit Exception

Recently something happened to my TD.Net environment. When running tests with TD.Net, its looking for nunit 2.4.6. This happens with any project that uses NUnit as my testing framework. No references to that version in any of my projects. Have un-installed / re-installed both the latest NUnit and TD.Net several times. TD.Net works fine ...

What is the best way to unit test a protected method in C++?

What is the best way to unit test a protected method in C++? In Java, I'd either create the test class in the same package as the class under test or create an anonymous subclass that exposes the method I need in my test class. Because neither of those methods are available to me in C++, what are suggested approaches for testing pr...

Do I test a class that does nothing?

In my application, I have two classes: a logger that actually logs to the database and a dummy logger that does nothing (used when logging is disabled). Here is the entire DummyLog class: class DummyLog(object): def insert_master_log(self, spec_name, file_name, data_source, environment_name): pass...

Unit testing an Asp.net MVC controller action

I have a controller action that checks this.User.Identity.IsAuthenticated What do you suggest how to tackle unit test on such an action? ...

How to interpret 'test every scenario you can think of'

I was recently tasked to, "Test every scenario you can think of and try to break the component" What might be sensible in 'everything' when the application is a website? NOTE: This particular site is ASP.NET with MS-SQL, however, I would like to know what would be covered in general as well. Thank you all for the great responses! ...

Proper application of Mock objects in Unit Testing

I've got a PresenterFactory that creates Presenter classes based on a Role parameter. Specifically, the Role parameter is an external class which I cannot control (IE 3rd party.) My factory looks something like this: public class PresenterFactory { public Presenter CreatePresenter(Role role, ...) { if (role.IsUserA("Manage...

How important is checking for bad parameters when unit testing?

Let's say I've got a method that takes some arguments and stores them as instance variables. If one of them is null, some code later on is going to crash. Would you modify the method to throw an exception if null arguments are provided and add unit tests to check that or not? If I do, it's slightly more complicated since javascript has m...

Eclipse classpath entries only used for tests

In Maven, you can have compile-time dependencies and test dependencies. This is a feature I love, and the M2Eclipse plugin makes this available in Eclipse, too, which is great. So if I add jmock.jar to my project as a test dependency, it will show up on the classpath for JUnit tests, but won't be present when I'm debugging the applicatio...

How to check if a private method was called with expected argument in unit test?

I am writing unit for a class which looks like following using nunit and Rhino mock. Class MyClass { private void M() { N("Hi"); } private void N(string text) { ........ do something } } For the unit test for method M I want to check if method N was called with argument "Hi". How do I do it? ...