unit-testing

When to use State vs Behavior Verification

In some cases its obvious when one or the other is warranted in other cases its not so clear. Take the following examples: A method which takes two inputs, performs a calculation and returns the result. A method which calls a factory object's Create method, passes the newly created object to the Add method of a collection object and re...

JUnit tests run in eclipse return errors even though I have expected annotation

(This is a follow up question to this one.) I'm having a problem with JUnit4 tests in eclipse. I'm trying to use the @Test(expected=...) annotation to unit test exception throwing. The problem is that when I run the tests, they come back as errors instead of passing, even though I'm expecting the exceptions to be thrown. I'm using ecli...

Parameter unexpectedly initialized when invoked from unit test

I have a unit test invoking a constructor, passing in a "null" on purpose to test the handling of the null. I expect the method invoked to throw an ArgumentNullException, but when I step through the code, I see the parameter has actually been initialised. This has me stumped, although my gut says it has something to do with the DI cont...

Jstestdriver setup and teardown

Hi all: Does anyone know the syntax for setUp and tearDown functions/methods for JsTestdriver? On their website they claim to be able to define it, but I can't get it right. Thanks. ...

How to do Unittests in Servlet-Applet scenario

How should I create & run unit-tests for a Java/Tomcat Servlet-Applet application? ...

The underlying connection was closed: An unexpected error occurred on a send.. Check that the Web server is still running and visible on the network.

I am getting this error when i run my ms unit test cases in the solution. If i run all the individual test cases its working and i am able to run the test cases. is there any fix for this? Am i missing something? ...

Eunit timeout doesn't work

Hi, I am trying to run all unit tests using eunit inside a folder but it seems like timeout always reset to 5 seconds. e.g. Module: -module(example). -include_lib("eunit/include/eunit.hrl"). main_test() -> % sleep for 10 seconds ?assertEqual(true, begin timer:sleep(10000), true end). Command line: Eshell V5.7.3 (abort wit...

Need ideas for a TDD Approach

We have just released a re-written(for the 3rd time) module for our proprietary system. This module, which we call the Load Manager, is by far the most complicated of all the modules in our system to date. We are trying to get a comprehensive test suite because every time we make any kind of significant change to this module there is h...

How do you write unit tests for your java servlets?

Hi, what are the best practices to unit test java servlets? By the way: this is a topic in which I have some dificulty: how do you unit test your java servlets? ...

How can I exclude a package from the clover coverage report (running from Maven)?

I'm generating clover coverage reports (using Clover's maven plugin), and I'd like to exclude a certain package from the coverage reports (specifically, because it's UI code that intentionally isn't covered by my unit tests, but the reason doesn't really matter.) I can see how to exclude that package from being instrumented (using in t...

How should I organize Python source code?

I'm getting started with Python (it's high time I give it a shot), and I'm looking for some best practices. My first project is a queue which runs command-line experiments in multiple threads. I'm starting to get a very long main.py file, and I'd like to break it up. In general, I'm looking for: How do python programmers organize multip...

How to unit test my models now that I am using Core Data?

I have been developing an iphone application using a domain model, and have put off the persistence aspect of the app until now. Core Data looks like a really good solution since I already have a well defined model but I am running into a snag with my existing unit tests. Here is simple example of what I have now: - (void)test_full_na...

Rhino Mocks expectation not returning collection correctly

I am new to Rhino Mocks, and using mock isolation frameworks in general for unit testing. I have written the following test, where I have set up an expectation for a mock IDataProvider object to return a collection of objects. The collection supplied has one object in it. When I run the test, the call to the IDataProvider returns a empt...

How do I use XMLUnit to compare only certain parts of files?

How do I use XMLUnit to compare 2 or more nodes (of the same name) in 2 different files? I have 2 XML files that look like this: <SearchResults> <result type="header"> ...ignore this.... </result> <result type="secondheader">...ignore this....</result> <result>....data1....</result> <result>....data2....</result> <result>.......

Django unit testing failures related to authentication settings

In Django, when I run "manage.py test", I get a lot of authentication related failures. Some examples: FAIL: test_password_change_succeeds -- AssertionError 200 != 302 FAIL: Logout without next_page option renders the default template -- AssertionError 200 != 302 And: Failed example: form.non_field_errors() Expected: [u'This...

JTA: how to be test JMS and JDBC failures?

Hi all, we're currently working on testing JTA failure behaviour, on a system that receives messages using JMS, persists them, and sends results using another class. The whole thing is tied together using Spring. Current unit tests use HSQLDB, Apache ActiveMQ and Bitronix for transaction management. Success with this has been limited, ...

How do you get unit tests to use routes in ASP.NET MVC?

I am writing unit tests against my ASP.NET MVC application, in particular I am testing an HtmlHelper extension method that I wrote. There is a line inside of the extension method: var innerHtml = htmlHelper.ActionLink(text, action, controller, routeValues, null); When I run this inside of my unit test, the href of the generated URL i...

Unit Testing the Data Access Layer

I want to test the data layer, how do I go about this? I am using NUnit for my business object testing. Must I use mock objects (which I have never used before)? I would appreciate any amount of input if someone can just guide me in the right direction. ...

Why do my Perl module tests fail when I run them with Test::Harness::runtests?

I have a Test::More test script for a module we have made. When running the test script by itself, it works just as expected. Since there are several tests we need to run, I made a Test::Harness file that run all scripts. However, when executing from the Test::Harness runtests the script returns errors. During debugging I tried to run ...

How Do I Use the app.config file with a Test Project

I using unit testing, to ensure that I can read connect string information from the ConnectStrings section of my app.config file. This works fine in the application proper, However when I attempt to generate a unit test for this under the Test Project, the dll.config file is being ignored, and the connectstring info from the machine.con...