Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am an entry level Java Programmer straight out of school. I have good knowledge and experience with J2SE. Can anyone advise me on how to improve or tune my skills towards being a Java white box tester? Wide range of inputs are welcome.

And what is Test Driven Development?

share|improve this question

migrated from stackoverflow.com Sep 6 '11 at 10:45

This question came from our site for professional and enthusiast programmers.

    
Why not Black box testing as well? –  Martijn Verburg Sep 6 '11 at 10:50
    
@Martijn, considering the background, most probably because of whitebox testing's technical challenges. Also, while black box techniques are very useful for developers, people with a good qualities for a developer don't make good black box testers, we're too curious and can get impatient. I know I did. –  StuperUser Sep 6 '11 at 11:11

5 Answers 5

The question specifically makes reference to "white box testing". This is where your tests have intimate knowledge of the internal structure of your code and assert behaviour at each step rather than just the input/output/side effect(black box testing). Whilst JUnit is excellent to do both, you need further additional frameworks in order to do this within the context of a unit test.

EasyMock and JMock are good frameworks to do this. I tend to favour JMock.

At the risk of starting a OT debate, you should think carefully about the implications of white box testing. White box tests are intimately tied to your code (obviously), and if not used carefully, mocking frameworks can cause your tests to be rather complicated, difficult to read and tend to be more brittle when refactoring.

I tend to stick to a mix of both. Black box tests wherever possible, and white box tests sparingly applied to riskier/more complicated code.

Of course the frameworks listed above can also be used in black box tests where the number of contributing (injected) classes is large and simple stubbing becomes unwieldly.

Regarding TDD - it's primarily a design enhancing approach to writing code, rather than simply a way of writing tests. The tests you have at the end are an important output, but moreover the approach is intended to enhance the design and stucture of your application.

share|improve this answer

I am not sure if my suggestion will be considered as tools for white box testing but you can also look at dbUnit for database-driven projects and Selenium for web testing(e.g. inspection of elements that should be existing based on some results).

share|improve this answer

Test Driven Development (TDD) and it's extended cousins, Acceptance TDD (ATDD) and Behaviour Driven Development (BDD) are useful techniques to learn as a tester in the Java ecosystem. I'll focus on TDD as you're looking for white box testing.

What is TDD? - At it's heart it's the practice of writing a failing test (red), making that test pass by writing an implementation (green) and then re-factoring. The Wikipedia Article is a sufficient place to start to find out further information. But the topic is vast, I recommend reading some of the well-known books in this space such as Test Driven Development by Example and Working effectively with legacy code. I'll also throw in a shameless plug for the TDD chapter in The Well-Grounded Java Developer

In the Java ecosystem, this means you want to learn:

  1. The JUnit library and/or the TestNG library.
  2. A mocking library such as Mockito or JMock
  3. A load testing tool to attack the code - JMeter
  4. The concept of Dependency Injection (a form of Inversion of Control)

And then practice, practice, practice, practice. Good Java white box testers are very rare, the best have written tests against a wide range of code bases.

HTH's get you started!

share|improve this answer
    
+1 excellent resources on test engineering. –  StuperUser Sep 6 '11 at 11:12
    
They are also useful techniques to learn as a developer in the Java ecosystem. As I understand, testers should do black box testing. –  Tom Sep 11 '11 at 15:22

I normally don't like to quote Wikipedia but the information on this article seems safe enough...

http://en.wikipedia.org/wiki/Test-driven_development

Essentially in lay terms it is a Test-First approach to software development were unit tests are designed and written to use cases first, then hard development occurs afterwards to help make those unit tests pass.

share|improve this answer

Junit is one of the best unit testing framework for the Java programming language. Its an open source framework to write and run repeatable tests.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.