This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I believe my problem may be due in part to some hierarchy in my application. I have com.myapp.utils, com.myapp.archive, etc. plus other com.somethingelse.authentication, etc. I'm trying to retrofit all of this with JUnit tests following the package path hierarchy.
I've created some <class>Test.java files matching my classes in com.myapp.utils, which run fine, and also a UtilsTestSuite.java. Launching UtilsTestSuite as a JUnit Test is successful too; it runs the various <class>Test.java tests it gathers together. So far, so good.
In com.myapp (so, one level up), I've created a ServerClassesTestSuite (see code below in case it's any help) and called addTestSuite( UtilsTestSuite.class ) and I intend to add others (ArchiveTestSuite.class, etc.), but running it I get an error:
junit.framework.AssertionFailedError: No tests found in com.myapp.utils.UtilsTestSuite
My intention is to create AllTests.java (maybe I'm naive here) to unite ServerClassesTestSuite and others I have yet to write at the same level.
The subject of this plea for help reveals that I don't completely grok the distinction between addTestSuite() and addTest(). Believe me, I've read pretty much every JUnit tutorial I've found on Google, most barely acknowledge the existence of TestSuite. The one that does gives an example, which I've followed here in ServerClassesTestSuite, but comment out the call to addTest() and don't even give sample code for what's passed to it as an argument. Yet, I figure, this addTestSuite()/addTest() is likely not even my problem.
Thanks for the help anyone can give,
Here's some of my code--dumbed way down to fit in here.
Yeah, addTestSuite really is a bit of a misnomer - you don't use it to add a TestSuite (doh!), but to add a single Test*Class* as a TestSuite. If you take a look at the source code, you will see that it's jsut a shortcut for
To really add an already existing TestSuite, use
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Feb 26, 2008
Thanks much, Ilja.
Joined: Feb 26, 2008
Okay, I've got my deeply hierarchical test framework going.
To give back a little here by presenting a different view than the tutorials I found and read, here's my take for anyone who wants to see a bit more code, corrected, than what I put above, plus lots of comments, some of which may be totally in error: