File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes best practise in testing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "best practise in testing?" Watch "best practise in testing?" New topic
Author

best practise in testing?

david santana
Greenhorn

Joined: Dec 08, 2011
Posts: 10
Hi, I'm a total beginner in testing so I don't know much about the best practice in this field..

when testing a website, should I make a test suite that contains test cases like this:

or should I just run the test cases one by one and change the baseUrl for each page?

if I should use the test suite, is it possible to put the @Before in the test suite instead of inside each test case? so that I only need to change the baseUrl once in a test suite...

thanks for being patient in dealing with my newbieness...
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

Yes,
1) A suite is often better because you can easily run all tests. In an IDE, you can do this by selecting the package. A suite lets you do the same in Ant though. Take a look at Classpath Suite so you can use wildcards rather than listing out each class one by one.

2) Not built in, but you can write a small amount of code to do so. Here's an example of setup before a suite and tear down after a suite. The only disadvantage is that you are running as a main method rather than via a junit runner. No green bar. (Built in you can run code before and after a class, but not a suite.)


[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
david santana
Greenhorn

Joined: Dec 08, 2011
Posts: 10
I'm testing 3 websites. each one consists of many pages. in this test:
1. should I test the trivial things (header, sidebar link) in every pages or just once in the main page?
2. I'm using eclipse, so should I use a separate package for each page and separate projects for each websites?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

There's no right answer to those. For #1, I would test it once because it is likely shared code. For #2, many organizational styles make sense. What you propose certainly does.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: best practise in testing?