Again, if the contract of that method says that a leading white space -- or some other irregularity -- causes a specific exception to be thrown, it is good that there are test cases to verify the contract.

Maybe it is not the test that you dislike, but rather the behaviour of the method? In that case the contract should be changed to say "any leading or trailing white space will be trimmed" or something like that. But that has nothing to do with the test being invalid IMHO.

Agreed, I don't like the behaviour of the class, but I also don't like adding a test which aims to guarantee that that behavior will not change. The implicit assumptions people make are not part of the contract of the method. The contract of the method is defined in the JavaDocs for the method (hence keeping JavaDocs up to date is so important), and for HttpClient also in the relevant RFCs and standards. It goes without saying that the behavior of HttpClient will change so we need tests that reliably show errors rather than tests which are constantly being changed because they're too strict - that just leads to tests failing tests being ignored.


Achieving 100% (or any other hard number) of code coverage is a lot of work, and almost never guarantees that the code is free of errors. Making some percentage of code coverage a hard requirement is usually missing the point. Of course, more coverage is usually good, but there's a point of diminishing return

Agreed, we need good test cases not just code coverage. The biggest advantage of having a set percentage coverage is that it (hopefully) sparks a test writing session when things fall below that level.


Anyway, while tests like the "pedantic" ones you outlined are probably not critical, I see no reason to throw them away if they're already present. They serve the very good purpose of testing error conditions and asserting the contract of the class under test.

Currently HttpClient has about 47% code coverage and there are almost none of these pedantic tests in our test suite. Much of the new test cases I add to improve code coverage will likely be these pedantic cases since we are generally pretty good at adding tests for major features. The question is then, is it worth adding these tests or is it likely to just cause so too many test failures in the future and diminish the effectiveness of our tests.


Just my two cents.

Thanks it's appreciated. :)


-chris


Regards,

Adrian Sutton.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to