R
Rhino
I have to say it is a bit frightening that there are big brownie points[ SNIP ]Rhino said:
My theory is rather weak so I'm not really up on the meanings of
"black box" and "clear box" testing, let alone the subtle differences
between them. Also, I'm not writing the code for anyone but myself
right now, except that I _would_ like to get one project's code
looking as professional as possible so that I could present it to a
prospective client or employer as a portfolio of what I can do. (And
then imitate that in future projects as well as gradually retrofit
other existing projects with what I've learned). With that in mind,
would a reasonable employer/client likely find it acceptable that I
just tested the methods I wrote and overrode myself in my classes or
are they going to see me as the biggest idiot since the development
of COBOL if I fail to observe these subtleties?
No word of a lie, just the fact that you're writing tests already gets
you some serious points with employers or clients. And the huge
majority of people that matter will be perfectly happy with you
writing tests for a class that focus on methods that are lexically in
the class. That's what I do myself.
for doing any testing at all: you'd think that would be absolutely
essential to any serious employer or client. I was just hoping to be
doing a reasonable amount of testing to look like I know what I'm doing.
No testing at all didn't seem like an option in any universe I want to
live in
You're right, I did misunderstand him in exactly the way you said.You perhaps misunderstood Eric - he didn't mean that there is a subtle
difference between black box and white box testing. There isn't -
those two techniques are quite different. He simply called the
specific point he was making subtle.
Good points. I'll review the Wikipedia definitions and try to rememberYou don't need to be a testing god - people make FT careers out of
understanding testing. But you should know what black box and white
box testing are, for example. The Wikipedia page on Software Testing
is not a bad start, IMO. Just bear in mind that their terminology and
definitions are debatable on some specifics, but this doesn't detract
from the overall discussion (in particular the first few sentences
under Non-Functional Testing are whacked, try to gloss over them).
the highlights.
I see that you've given some good concrete suggestions for tools to useYou'll end up doing a fair bit of reading and playing with code to get
a good handle on testing overall, but it won't take all that long to
get a good grip on the basics.
I will make a few personal recommendations, which shouldn't be taken
as complete. This is based on going on ten years of J2EE work, so
depending on what kind of coding you're doing YMMV...some.
1. Code reviews/inspections and static code analysis with tools _are_
a form of testing. Keep them in mind.
in upcoming paragraphs. Are any of these static code analysis tools? If
not, can you suggest some good ones? I'd love to have some feedback on my
code via code reviews too but that's a little difficult to do. It's not
realistic to full (non-trivial) classes in the newsgroup so I just pick
and choose especially concerning problems and post snippets reflecting
them. I'm sure that you folks are all too busy to do detailed
walkthroughs of dozens of classes with hundreds of lines of codes in many
of them ;-) I must see if there is a local Java user group in this area
and see if I can develop a few buddies for doing code walkthroughs....
2. Integration tests are as important as unit tests. In a J2EE web
application these are indispensable - you may have hundreds or
thousands of unit tests all pass but still have integration tests not
pass. You'll hear a lot of people, myself included, refer to a
specific class of integration tests as functional tests - we mean
"application functions from the user perspective" when we use
"functional" in that regard.
Examples of integration/functional tests in a J2EE web app range all
the way from ensuring that good things happen in the logic when you
click that "Transmogrify" button all the way to doing a complete pass
through a use case and making sure that your "Issue Fishing License"
logic works in Angler Administrator 2010.
Myself I use Selenium IDE/RC in conjunction with the JUnit framework
to write these kinds of tests.
3. Code coverage - Huge, IMO. How can you know that your unit tests or
integration tests (or even human-tester-driven acceptance tests) are
doing any good unless you know how much of the code is actually being
exercised? Code coverage is very simple to do, and for starters you
can't go wrong investigating Emma or Cobertura. These simply
instrument the Java bytecode, such that when the bytecode is executed
(by any mechanism) coverage counts by line/branch/method/class/package
are written to HTML or XML reports.
4. Carefully consider the issue of test data - test SQL scripts, mock
data, in-memory databases (see http://www.mikebosch.com/?p=8) etc.
5. Your tests are themselves defective. The sad truth is that if the
core source code you just wrote is riddled with defects, then so
probably are your tests.
Agreed! However careful and thorough you think you are, you're bound to
have made a few unreasonable assumptions, been unaware of various gotchas
in the Java API, etc. etc.
Sad but true....Main take-away here is, be aware that just
because all your unit tests pass, some not insignificant percentage of
those results are wrong.
Agreed. Those other levels of testing - and the other people we involveAs a side note, this is where the higher-level layer of integration
tests also helps - it can assist in identifying flawed unit tests.
in our testing - make sure that everything anyone on the team can think
of gets covered.
Thanks for all the great suggestions, Arved!
I've been holding off on learning about the other testing tools until I
had a bit more time but maybe I really should get at least basic
familiarity with the key ones NOW. Then I can include those test results
in my "portfolio" and show employers/clients that I have a serious
professional attitude, even if my chops are not entirely as fluent as I
would like yet....