BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

JBuilder X and abstract test classes

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Enterprise
View previous topic :: View next topic  
Author Message
geoffblanduk_nospam@yahoo
Guest





PostPosted: Wed Dec 21, 2005 8:50 am    Post subject: JBuilder X and abstract test classes Reply with quote



I have an abstract class that provides a lot of functionality but is
available in many "flavours" provided by subclasses.

abstract class Super {
abstract void initialise();
void foo1();
void foo2();
}

class ChildA extends Super {
void initialise() {...some code here...}
}

class ChildB extends Super {
void initialise() {...some code here...}
}

.....

class ChildZ extends Super {
void initialise() {...some code here...}
}


Now I'm creating my test cases as follows;

abstract class SuperTest {

Super testInstance;

abstract void createChild();

protected void setUp() throws Exception {
super.setUp();
testInstance = createChild();
}

public void testFoo1() {
assert(expectedResult, testInstance.foo1());
}

public void testFoo2() {
assert(expectedResult, testInstance.foo2());
}
}

class ChildATest extends SuperTest {
void createChild() {
return new ChildA();
}
}

class ChildB extends Super {
void createChild() {
return new ChildB();
}
}

.....

class ChildZ extends Super {
void createChild() {
return new ChildZ();
}
}


This seems to be common-sense and I've read articles saying that
"super-test-classes" and inhertitence of tests is a "good thing".

But I can get JBuilder to work with it. JBuilder fails because it
attempts to create and run the SuperTest class which is of course
abstract.

The work around is to not have SuperTest abstract and have specific
tests in each of the sub-classes, but this is just messy and duplicates
a lot of code.

Anyone got a fix for this?

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Enterprise All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.