This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I'm having problems creating a TestSuite in JUnit4 under MyEclipse. I realize this is because, from what I've been able to find, that TestSuites really aren't supported in 4 (which makes them more difficult to use... <g> .
So, if I have two play classes: Calculator and Hello and two JUnit TestCases, how do I test both of these classes at once? I tried creating a TestSuite anyway, but apparently didn't have the correct constructor method in the actual classes. "JUnit in Action" discusses this issue, but relative to JUnit 3.8.
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
Possible, but the assert command, in the sample code I downloaded, didn't work at all -- and I'm using Java 5. The code didn't give any errors either. It just didn't do anything...I got a green JUnit test case when there should have been an error. To futher confuse things, the sample code had both types of assert statements (assert(...) and assertEquals(...).
I think what the other person said is probably the culprit...asserts are disabled by default. I thought of that, but wasn't sure when the AssertEquals(...) seemed to work OK.
The JUnit assertXxx methods don't use the assert keyword and thus aren't disabled by default. (though as of JUnit 4 they will throw AssertionErrors, which is what is thrown by the assert keyword). As mentioned previously, the assert keyword *is* disabled by default. One way to enable it is to use the -ea (standing for enable assertions) JVM flag.