This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Extending JUnit

 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How many people use stock JUnit, and how many people have their own local extensions? We have a few, the absolute favorite being a method canRun() in our own TestCase subclass, and a run() method that calls it to decide whether to skip certain tests on certain platforms. I wrote this up in the Journal a while back.

Anyway, I know I could answer this by looking at the book's web site, but does "JUnit Recipes" talk about writing JUnit extensions at all?
 
author
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JUnit Recipes does not provide much about specifically how to extend JUnit. I rarely find it necessary to do so for my testing: I tend just to use the existing test runners and all the prefab extensions (HtmlUnit, XMLUnit, Cactus, ...).

Many of the questions we get on the JUnit Yahoo! group garner suggestions for writing custom test runners, but rarely do we get a question that leads us to consider extending the framework itself.

I consider JUnit's framework to be adequate for my needs, but then, perhaps I'm just not solving hard enough problems.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:
How many people use stock JUnit, and how many people have their own local extensions?



The only "local extensions" I remember using are project specific assert methods...


... a method canRun() in our own TestCase subclass, and a run() method that calls it to decide whether to skip certain tests on certain platforms. I wrote this up in the Journal a while back.



Well, recipe "4.6 Separate the different kinds of test suites" might be interesting to you...
 
author & internet detective
Posts: 39890
798
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest,
We have several types of minor extensions:
- project specific asserions
- general assertions (for collections and other data structures)
- use of test collector to collects tests by package using reflection
- section 508 test (plugs into each application to test for section 508 compliance)
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jeanne Boyarsky:
- section 508 test (plugs into each application to test for section 508 compliance)


Jeanne, I'd love to hear more about this? What's section 508 and what does the test do?
 
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there any JUnit extensions to test mult-threaded applications?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:
Are there any JUnit extensions to test mult-threaded applications?


http://today.java.net/pub/a/today/2003/08/06/multithreadedTests.html
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
What's section 508



As far as I can tell, it's an accessibility law: http://www.section508.gov/

what does the test do?



That I would like to know, too!
 
Jeanne Boyarsky
author & internet detective
Posts: 39890
798
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, section 508 is an accessibility law. All applications developed for the federal government are required to meet the 16 provisions. The Department of Health & Human Services has a chart that lists the provisions in a clear way.

There are many free tools that let you run your generated HTML through and highlight your Section 508 violations. But it is quite tedious to do this for every single JSP (and every single display combination for those JSPs) on a regular basis. It is also quite tedious to look at the results of these tools. After a couple of experiences with 508 violations slipping through after we "implemented Section 508", it was time to do something about it. Enter Junit - great for tedious, repeatable activities.

Many of the 508 practices are very programatic. For example, practice a states you must have an alt tag for every image. It's very easy to go through a JSP and check for that. We also check for form labels, table headers/summaries and a couple other things. We check for html and struts tags. Granted junit can't check for everything, but some of the 508 practices (like background colors) need to be checked by hand even after using the 508 tools anyway.

Our Section 508 test class is an abstract junit test case (extends TestCase) that provides tests for some of the provisions. It resides in a library jar with our other common stuff. Each application subclasses this test case and implements the method where we state the web project name. After that, the 508 test loops through the jsp directories and gathers them all. It then uses JBs parameterized test case pattern to run each test for each jsp and report the results as separate tests.

Our Section 508 flags a violation about once a week during heavy development. We run it with our other Junit tests, so it gets run often. So it's definitely keeping our code compliant.

Well this was long. I hope I didn't give you guys too much detail.
 
Jeanne Boyarsky
author & internet detective
Posts: 39890
798
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably should mention it is a US law
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find that the base Junit provides enough functionality to do the base testing. I have used some of the Junit extentions such as Cactus, and Struts Test Case. Both of these are great for testing Struts Actions, and servlets.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne, that was a very interesting read, thanks!
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne - are the Test Case extensions for Section 508 something that you can share?

Thanks in advance.
 
Jeanne Boyarsky
author & internet detective
Posts: 39890
798
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Irwin,
The commercial (non-junit) ones like hisoftware's, and pagescreamer have free versions on the web where you can run an HTML file through.

The junit extension is something I wrote. If you PM me your e-mail address, I can send it to you.
 
Sheriff
Posts: 15048
252
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jeanne Boyarsky:
The junit extension is something I wrote. If you PM me your e-mail address, I can send it to you.



Jeanne,

Me, too! (firstName at javaranch.com) My current project is for the Ohio Dept of Jobs and Family Services and it's partially federally funded so we have to comply with Section 508.

TIA.

Junilu
 
Jeanne Boyarsky
author & internet detective
Posts: 39890
798
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu,
I'll send it out tomorrow.
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!