baseten / UnitTests / TestLoader.m

// TestLoader.m
// BaseTen
// Copyright (C) 2006-2008 Marko Karppinen & Co. LLC.
// Before using this software, please review the available licensing options
// by visiting or by contacting
// us at Without an additional license, this software
// may be distributed only in compliance with the GNU General Public License.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0,
// as published by the Free Software Foundation.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
// $Id$

#import "TestLoader.h"
#import <SenTestingKit/SenTestingKit.h>
#import <BaseTen/BaseTen.h>
#import <BaseTen/BXDatabaseAdditions.h>
#import "MKCSenTestCaseAdditions.h"

#import "ConnectTest.h"
#import "EntityTests.h"
#import "ObjectIDTests.h"
#import "FetchTests.h"
#import "CreateTests.h"
#import "ModificationTests.h"
#import "ForeignKeyTests.h"
#import "ForeignKeyModificationTests.h"
#import "MTOCollectionTest.h"
#import "MTMCollectionTest.h"
#import "UndoTests.h"
#import "ObjectTests.h"

@interface SenTestSuite (BXAdditions)
- (void) addSuitesForClasses: (NSArray *) anArray;

@implementation SenTestSuite (BXAdditions)
- (void) addSuitesForClasses: (NSArray *) anArray
	TSEnumerate (currentClass, e, [anArray objectEnumerator])
		SenTestSuite* suite = [[self class] testSuiteForTestCaseClass: currentClass];
		[self addTest: suite];

@implementation BXTestLoader
- (void) test
	NSArray* simpleTestClasses = [NSArray arrayWithObjects:
		[ConnectTest class],
		[EntityTests class],
        //[ObjectTests class], //FIXME: enable this. It still requires a modified OCMock, though.
		[ObjectIDTests class],
		[CreateTests class],
	NSArray* useCaseTestClasses = [NSArray arrayWithObjects:
		[FetchTests class],
		[ModificationTests class],
	NSArray* relationshipTestClasses = [NSArray arrayWithObjects:
		[ForeignKeyTests class],
		[ForeignKeyModificationTests class],
		[MTOCollectionTest class],
		[MTMCollectionTest class],
		[UndoTests class],
	SenTestSuite* simpleSuite = [SenTestSuite testSuiteWithName: @"SimpleTests"];
	[simpleSuite addSuitesForClasses: simpleTestClasses];
	SenTestSuite* useCaseSuite = [SenTestSuite testSuiteWithName: @"UseCaseTests"];
	[useCaseSuite addSuitesForClasses: useCaseTestClasses];
	SenTestSuite* relationshipSuite = [SenTestSuite testSuiteWithName: @"RelationshipTests"];
	[relationshipSuite addSuitesForClasses: relationshipTestClasses];
	SenTestSuite* bxSuite = [SenTestSuite testSuiteWithName: @"BaseTenTests"];
	[bxSuite addTestsEnumeratedBy: [[NSArray arrayWithObjects:
		nil] objectEnumerator]];
	SenTestRun* run = [bxSuite run];
    //SenTestRun* run = [(SenTestSuite *) [SenTestSuite testSuiteForTestCaseClass: [FetchTests class]] run];
	STAssertTrue (0 == [run failureCount], @"Expected tests to succeed.");

@implementation BXTestCase
static void
bx_test_failed (NSException* exception)

- (void) logAndCallBXTestFailed: (NSException *) exception
	[self logException: exception];
	bx_test_failed (exception);

- (id) initWithInvocation:(NSInvocation *) anInvocation
	if ((self = [super initWithInvocation: anInvocation]))
		[self setFailureAction: @selector (logAndCallBXTestFailed:)];
	return self;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.