unit-testing

Rhino Mocks AAA Quick Start?

Hi, I've been looking around for some decent information on using Rhino Mocks 3.5+ with the AAA syntax. I find a lot of blogs that have a mix of things from the old and new which seem to make it more difficult to figure out how to use it. Would would be great would be if there were a Rhino Mocks AAA Cheat Sheet like was done for an earl...

Unit testing Jade

Hi, What techniques and design strategies have people used to aid in unit testing Jade applications? In particular, how do people typically go about testing Behaviours - which are tightly coupled to the Agent instance and the Jade environment? I'm aware of the JadeMX project, but this appears to be geared more towards system testing - ...

looping in unit test bad?

I have a unit test that relies on a random dice roll. I roll a 20 sided die and if the value is 20 it counts as a critical hit. What I'm doing right now is rolling the 20 sided die up to 300 times. If any one of those rolls is a 20 then I know I had a critical hit. Here's what the code looks like: public class DiceRoll { public in...

What are mock objects in Java?

I like to know what mock objects are in Java. Why do we create them and what are their uses? ...

Refactoring Service Layer classes

My company is on a Unit Testing kick, and I'm having a little trouble with refactoring Service Layer code. Here is an example of some code I wrote: public class InvoiceCalculator:IInvoiceCalculator { public CalculateInvoice(Invoice invoice) { foreach (InvoiceLine il in invoice.Lines) { UpdateLine(il); ...

Testing, Mocking framework support for recording annotations (preferrable easymock solution)

We have developed some code which analyzes annotated methods and adds some runtime behaviour. I would like to test this. Currently I am hand-coding stubs with certain annotations for setting up my test-case. Usually I am using a mocking-framework (currently easymock) to avoid hand-coding test-doubles (stubs or mocks). But I haven't foun...

Do large enterprises utilize mocking/stubbing?

Has anyone worked at a large company, or on a very large project, that successfully used unit testing? Our current database has ~300 tables, with ~100 aggregate roots. Overall there are ~4000 columns, and we'll have ~2 Million lines of code when complete. I was wondering - do companies with databases of this size (or much larger) actu...

Automatic generation of unit tests for Java?

Any tool for automatically generating unit tests for Java code? UPDATE: Primary intended use is to quickly generate unit tests for legacy code that is going to be refactored. No need to automatically keep the tests in sync with the code after automatic generation. Almost same question was asked here, but the answer was for .NET inst...

Can I use osql with Sql server Compact Edition

I have a file that contains lots of insert statements to populate my compact edition database with test data. I have been running the file from Sql Server Management Studio each time I run a unit test (I'm using NUnit). Now I want to automate the running of database scripts for each test. I'm trying to use osql as described in this artic...

@BeforeClass and inheritance - order of execution

I have an abstract basis class, which I use as a basis for my unit tests (TestNG 5.10). In this class I initialize the whole environment for my tests, setting up database mappings, etc. That abstract class has a method with a @BeforeClass annotation which does the initialization. Next thing, I extend that class with specific classes in w...

Debuggin UnitTests in ASP.Net MVC

Hello, I'm having a problem debugging my unit tests in ASP.Net MVC. Whenever I try and debug a selected test, the breakpoint I set turns in a hollow circle with a warning sign. When I hover over it I get the following error: "The breakpoint will not currently be hit. No symbols have been loaded for this document." I've searched on th...

Can I unit test an inner function in python?

Is there any way to write unittests or doctests for innerfunc? def outerfunc(): def innerfunc(): do_something() return innerfunc() ...

iPhone unit test linking problem, can't find DevToolsBundleInjection.framework

I'm trying to setup application unit tests for my iphone app. So I made a copy of the app target, and a unit test bundle target as described in apple's documentation (http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html) After following A...

Boost Unit testing with Allegro Graphics Library

I'm trying to use boost unit testing alongside the Allegro graphics library, but both require main() alterations / overwrites. Has anyone had any experience using both? Edit 1/29/2010: I've refrained from selecting an answer until I can verify one or another, and due to the... sparse nature of the answers. ...

JUnit extend base class and have tests in that class being run

I am using JUnit 3 and have a situation where often I have to test that an object is created correctly. My idea was to write a class MyTestBase as shown below and then extend from that for the situation specific unit tests. However in the example I've given, MyTests does not run the tests in MyTestBase. public class MyTestBase extends...

How to unit test Java code that is expected to run within an applet Security Manager

I have some Java library code which sometimes runs as an unsigned applet. Because of this it is not always allowed to do some operations (for instance checking for system properties). I would like to run some unit tests with an Applet-like security manager so that I can verify that the code is either not performing any restricted oper...

Grabbing the output sent to Console.Out from within a unit test?

I am building a unit test in C# with NUnit, and I'd like to test that the main program actually outputs the right output depending on the command line arguments. Is there a way from a NUnit test method, that calls Program.Main(...) to grab everything written to Console.Out and Console.Error so that I can verify against it? ...

Testing that serializable attributes are set

I'm writing a unit test to verify that the serializable attributes are set on my class. I thought I was on the right way, but for some reason I can't find the attribute types. Here is my class: [DataContract] public class User { [DataMember] public int Id { get; set; } } And a unit test for checking the attributes: [Test]...

Mock object returning a list of mocks with Moq

I am trying to test the following code public void CleanUp() { List<ITask> tasks = _cleanupTaskFactory.GetTasks(); //Make sure each task has the task.Execute() method called on them } In my test I create a mocked implementation of _cleanupTaskFactory, and I want to stub the GetTasks() method to return a ty...

Implicit typing and TDD

I just read this post and it makes the case against implicit typing using when starting out with Test driven development/design. His post says that TDD can be "slowed down" when using implicit typing for the return type when unit testing a method. Also, he seems to want the return type specified by the test in order to drive development...