unit-testing

Java: Illegal Argument Exception

I'm getting an IllegalArgumentException, but I can't figure out why. The function I'm trying to access: private static Player checkEvents(Player[] players, GameMaster bananas) The problematic code: @Test public void testCheckEvents() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, I...

Unit testing opaque structure based C API

I have a library I wrote with API based on opaque structures. Using opaque structures has a lot of benefits and I am very happy with it. Now that my API are stable in term of specifications, I'd like to write a complete battery of unit test to ensure a solid base before releasing it. My concern is simple, how do you unit test API based...

Java jUnit: Test suite code to run before any test classes

I have a test suite class: @RunWith(Suite.class) @Suite.SuiteClasses({ GameMasterTest.class, PlayerTest.class, }) public class BananaTestSuite { What annotation do I need to use to make a function in this class run before any of the classes containing actual tests? Right now, I'm doing this, and it works, but it's not as read...

Java: Mock testing probably with Mockito

I think I'm not using verify correctly. Here is the test: @Mock GameMaster mockGM; Player pWithMock; @Before public void setUpPlayer() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { pWithMock = new Player(mockGM); } @Test public void mockDump() { pWithMock.testDump(); ...

Level of detail of your unit tests

I wanted to start a discussion about the details that you cover in your unit tests. Do you test major functionalities, that consist of several methods doing one task at once with one test? or maybe you even test automatic properties? Because, for example, I see little value in writing a test that would test only this: public Email ...

Javascript unit testing in eclipse

I am doing a firefox extension using eclipse and need to know how I can do unit testing for that project. ...

Can you mock an object that implements an interface AND an abstract class?

Is it possible to use Moq to mock an object that implements an interface and abstract class? I.e.: public class MyClass: SomeAbstractClass, IMyClass Can you mock this? ...

Primitive unit-tests

Hello! Is it worth to write unit-tests for such the simple code: public class TableController { private TableView view; public TableController(TableView view) { this.view = view; } public void onShowTable() { view.showTable(); } } I have a lot of such very simple code in my projects which connects controllers, vie...

NHibernate unit test cases 101

I found what I thought was a great article by Ayende on creating a simple base test fixture for NHib unit testing with SQLite. My question here is the code for a test case in concrete test fixture. In EX_1 below, Ayende wraps both the save a fetch in a transaction which he commits, and has a Session.Clear in between. This works, or cour...

Entity Framework 4.0 Unit Testing

Hi, I've implemented unit testing along the lines of this article with a fake object context and IObjectSet with POCO in EF4. http://blogs.msdn.com/adonet/archive/2009/12/17/test-driven-development-walkthrough-with-the-entity-framework-4-0.aspx But I'm unsure how to implement a couple of methods on my fake object context for testing. ...

Mocking a javascript method with ScrewUnit

Hi. I have a simple validation method as follows function someMethod { //some processing } I want to unit test this method. What is the simplest way I can mock it. Usually if I have an object as follows: var someObject = function() { reload : function() { //reload logic here } } I can stub someObject and then check if...

Subsonic 3 ActiveRecord Setup() behavior

Been a long time user of Subsonic 2.x and have used 3.x a bit, but I've recently started transitioning our use of SS from using repositories to ActiveRecord instead. I'm currently stumbling on some of our unit tests and I wonder if it's perhaps because I'm misunderstanding the intent of the Setup() method. Alas, the only documentation ...

Most efficient way to initialize a large block of doubles in C

What's this easiest / most efficient way to initialize these blocks of doubles, preferably at compile time: #define N 1000 double mul1[N][N] __attribute__ ((aligned (64))); double mul2[N][N] __attribute__ ((aligned (64))); They're used for "const" read only test data. ...

DB-intense "unit-tests" in times when hardware is cheap

I was thinking about well known article "Hardware is Cheap, Programmers are Expensive" by Jeff Atwood and a recommendation of "Keep the Build Fast" by Martin Fowler. My tried approaches: I've suffered from too slow tests which was caused by intensive use of database. I like that it is cheap.. at the beginning. I've tried a multitiered...

Best practices writing unit tests with NHibernate

I'm new to NHibernate (+Fluent), and I can't decide on what's the best strategy when it comes to structuring my code to make it testable. I have a plain structure including a domain model, mappings to map the model to database, and a few classes with behavior which will work towards the model classes and do transactions for updating and ...

Seam unit test can't connect to JBoss4.0.5GA

Does anybody know how to connect with JBoss4.0.5GA in Seam2.2.0GA unit test? I'm using Seam2.2.0GA with the embeded JBoss to run the unit test, the module needs to call old JBoss server (EJB2, because the vendor locked in JCA has to deploy on old JBoss). it's typical seam test case, and I can't get it connect to JBoss4.0.5GA by using jbo...

Question about NUnit

I am a college student that makes his programs here and there in c#, mostly scientific simulations. Is there any use in learning NUnit? I keep hearing people talking about it but I don't fully grasp what it is in the first place. Is it something that every programmer should use, or something that is more suited for big projects with lots...

string.c test suite

For practice I decided to rewrite string.c in C. I can not find online (via google or other search engines) a test suite for either the entire standard or for specifically string.h More specifically I am looking to see if my strcat(), strncat(), strchr(), strrchr(), strcmp(), strncmp(), strcpy(), strncpy(), strlen(), and strstr() func...

Is it possible to talk to the iPhone simulator/device.

I need to automate the build/deploy process for my iphone applications from a script. I can use xcodebuild to build the project, then use Applescript to deploy and debug/run the application. Assuming the application will stop by itself after a while, I need to collect the generated logs for verification. But the problem is I have no way ...

c# Rhino mocks - Is this an appropriate use of mocks?

Forgive me for my ignorance. I'm trying to learn Rhino. public Foo(Stream stream) { if (stream == null) throw new ArgumentNullException("woot"); if (!stream.CanRead) throw new NotSupportedException("sporkish"); if (!stream.CanSeek) throw new NotSupportedException("monkey"); } I would like to test this function with a NUni...