Meaningless Drivel is fun!*
The moose likes Testing and the fly likes java AssertionErrors from an applet to a junit test Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "java AssertionErrors from an applet to a junit test Class" Watch "java AssertionErrors from an applet to a junit test Class" New topic
Author

java AssertionErrors from an applet to a junit test Class

Amaru Shakur
Ranch Hand

Joined: Jul 17, 2008
Posts: 50
ok so i want to give a preface that this wasnt my idea but i "must" be able to do regular asserts in order to test code inside an applet (like very simple stuffs that can be covered by the java Asserts , however in order to view the results it would be highly favored if i could have junit collect it due to junits very nice html list of erros and failed and passed tests).

this is what i did

i made an object lets call it FOO that holds AssertionErrors (you can populate it and "run it" which prints out all of the erros and their stack traces and you can print out the garbage (anything that might have been stored in there that isnt an assertion error and clear all of the garabage). Now rather than just calling the run method of this object at the end of my applet i would like to be able to initiate these testing protocols from outside the applet.

the only thing i was thinking of that i know would work is making this FOO class a static class and then having a driver call its run method and show all the exceptions stored in it with the respective stack trace. (but i still wont have the nice junit html output).

however is there any way i could keep FOO as a non static class populate it in the applet and some how send it to a junit class to pull all the garage out of it and show that as errors and all the AssertionErros in it as failed tests so i have junits nice html display sheet?


Even though im marked for death I will spark till i loose my breath
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30353
    
150

Amaru,
The static class thing sounds feasible. (Although still a hack.) My personal advise would be to ask the person who required the regular Java assert approach and ask what he/she thinks you should do. Presumably that person has thought about the idea since that person is mandating it.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Amaru Shakur
Ranch Hand

Joined: Jul 17, 2008
Posts: 50
well really i dont think the person knows 100% what they want, they just want any testing in the applet which is pretty hard to test in my opinion (well all i know how to test is the components it works with but the applet itself is pretty hard (i even looked at jmeter but thats something for another day because its not focused on testing the applet it at best is could only tell me if the applet is a source of poor performance on other resources, i never did any unit testing focused on applets, its mostly been with databases and java interacting with them (through ejbs or spring ect)).

so in reality i think im just going to do some regression testing and keep it below the surface of the gui (no watir or selenium stuff).

but i was wondering if there are any other ways to test an applet or any good sources to look at.

the person mandating just wants any tests to test the applet for the sake of testing, however they would prefer if they had them similiar to the other unit testing (in those junit html pages).
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30353
    
150

Amaru,
Take a look at Abbot's FAQ where they describe unit testing applets.

If the person giving you the requirement wants test similar to the other JUnit tests, Abbot is more what they want. Abbot uses JUnit not plain Java asserts.

[edited to fix typo]
[ November 12, 2008: Message edited by: Jeanne Boyarsky ]
 
Consider Paul's rocket mass heater.
 
subject: java AssertionErrors from an applet to a junit test Class