unit-testing

Source code is in JDK 1.4 and JUnit test cases in JDK 1.5

I am working on a project that is using JDK 1.4 and I am planning to write JUnit test cases in JDK 1.5 for several reasons like: I wanna explore JDK 1.5 to use Mocking frameworks more efficiently. Is it a good idea to do so?? (I've created two projects in Eclipse and am trying this) ...

NET Ria Services - Unit testing business logic

Hello, When reading the overview document, there are examples of how to test GetSalariedEmployee and InsertEmployee. When trying to code a test for UpdateEmployee i want to check that repository's Attach method is called with the two parameters, but ChangeSet is null when there are no changes, so no calls can be made to ChangeSet.GetOr...

UnitTest frameworks for AS2?

I have just tried out ASUnit and it wasn't a success, so I'm looking for something simpler, no need for fancy UI. trace output is fine. ASUnit was not a success because it for some strange reason generated AllTests.as files in all subdirs of /Applications. I can't figure out how to stop this from happening, so I'm looking for something ...

Why is it so bad to mock classes?

I recently discussed with a colleague about mocking. He said that mocking classes is very bad and should not be done, only in few cases. He says that only interfaces should be mocked, otherwise it's an architecture fault. I wonder why this statement (I fully trust him) is so correct? I don't know it and would like to be convinced. Did...

What is the name of the pattern?

Hi. I often design system where I have a class in my system that has a bunch of protected methods. The protected methods are that because they should be accessible to specializations, and as such, I consider the protected methods to be a contract between my general class and any specialized classes. Therefore I want to test that these...

how to write tests without so many mocks?

I am a heavy advocate of proper Test Driven Design or Behavior Driven Design and I love writing tests. However, I keep coding myself into a corner where I need to use 3-5 mocks in a particular test case for a single class. No matter which way I start, top down or bottom up I end up with a design that requires at least three collaborators...

iPhone: Application Testing and Core Location

I'm trying to implement Application Tests as described here. So far, so good, but i fail to test, for instance, the location of the device using Core Location. I have added the appropriate Framework to the Target, and have initiated the update of location, but i have no clue of how to wait for the location to be loaded, the test suite ju...

Does a Unittest has to have an Assertion like "assertEquals(..)"

Hi I have a little JUnit-Test that export an Object to the FileSystem. In the first place my test looked like this public void exportTest { //...creating a list with some objects to export... JAXBService service = new JAXBService(); service.exportList(list, "output.xml"); } Usually my test contain a assertion like assert...

Testing Finalizers and IDisposable

Hi, The question is how can I test the fact that object disposes resources when finalise is called. The code for the class: public class TestClass : IDisposable { public bool HasBeenDisposed {get; private set; } public void Dispose() { HasBeenDisposed = true; } ~TestClass() { Dispose(); } } Plea...

Unit Testing & Primary Keys

Hi, I am new to Unit Testing and think I might have dug myself into a corner. In your Unit Tests, what is the better way to handle primary keys? Hopefully an example will paint some context. If create several instances of an object (Lets' say Person). My unit test is to test the correct relationships are being created. My code is t...

Is log4net killing my WCF unit tests?

I have three projects in my solution: A WCF web service which provides functionality I want to test A Web Application which calls that web service A test project which runs tests on the service. The web service and the web application both use log4net with separate configuration files and this line in the AssemblyInfo.cs for configur...

iPhone development Unit Testing Linking Problem

I've been trying to determine the cause of this error for days now. Tried doing simple projects by I could not get the unit tests to work? Does anyone know how to solve this problem? Building target “ChildTests” of project “Person” with configuration “Debug” — (2 errors) Linking /Users/me/Desktop/Person/build/Debug-iphonesim...

Should you have an interface for all objects/classes

As part of process improvements we are trying to ensure that all our projects have suitable unit tests, as there is a bit of education required in house I am trying ascertain what exactly is the best way to ensure we are making our classes as 'testable' as possible. I suspect that we will start moving down the Mock object route and wit...

Rails Test & Mocha: How to stub specific model - conditional any_instance ?

I want to stub just a specific model, but not only a specific object and not every instance E.g. Given class 'Person' with attributes 'name' (string) and 'cool' (boolean). We have two models: person_bill: name: bill cool: false person_steve: name: steve cool: false Now I want to stub just steve, which works alright: p1...

Is there a way to tell whether a function is getting executed in a unittest?

I'm using a config file to get the info for my database. It always gets the hostname and then figures out what database options to use from this config file. I want to be able to tell if I'm inside a unittest here and use the in memory sqlite database instead. Is there a way to tell at that point whether I'm inside a unittest, or will...

How to decorate a class as untestable for Code Coverage?

Hi, Background: Visual Studio 2008, C#, .Net 3.5. I have a number of utility classes that are simply not unit-testable. This is mainly because they interact with resources (e.g. databases, files etc). Is there a way I can decorate these classes so that the Visual Studio Code Coverage engine will ignore them, so not decreasing the code...

testing threaded code in ruby

I'm writing a delayed_job clone for DataMapper. I've got what I think is working and tested code except for the thread in the worker process. I looked to delayed_job for how to test this but there are now tests for that portion of the code. Below is the code I need to test. ideas? (I'm using rspec BTW) def start say "*** Starting...

Is there a way to hook or intercept CoGetClassObject and/or CoCreateInstance calls?

I'd like to intercept the COM CoCreateInstanceEx and/or CoGetClassObject functions to replace a class with a testing shim in a unit test. This will only be for a single CLSID; all others can go through unchanged. Is there a way to do this without horrible, evil hacks? ...

How to test duplicate email addresses in .NET MVC

I have added functionality to the Accounts Controller -> Registration ActionValidateRegistation function to test for blanks in the user registration form. I now want to throw an error to the form if the email address the user entered is already in the system. I have added the function checking for the duplicate email address at the en...

Custom test runner for Ruby (and shoulda)

I want to modify the test runner when using Ruby and shoulda. The standard runner produces output like this: .... Finished in 0.009167 seconds 4 examples, 0 failures As a starting point, I'd like to be able to modify this. Later, I want to create custom HTML output. How do I get started on this? I've done a lot of googling, but can...