Uncle to be
Tuesday, December 31st, 2002I found out at Christmas that I am to become an Uncle in July. Scary. Congratulations to Patrick (my brother) and Sonja. I guess one good thing about being in London is that I won’t have to change nappies :-)
I found out at Christmas that I am to become an Uncle in July. Scary. Congratulations to Patrick (my brother) and Sonja. I guess one good thing about being in London is that I won’t have to change nappies :-)
Consider the following test:
[Test]
[ExpectException(ExceptionType)]
public void ExceptionThrownByVerifier() {
doSomeSetup();
doSomeProcessing();
callSomethingThatThrowsTheException();
}
This is intended to test that callSomethingThatThrowsTheException() throws an excption. And lets say it passes.
The test is right - yeah? Wrong
If doSomesetup() throws an Exception then this is testing nothing - I’ll never know - and the test won’t tell me that it is useless.
The correct way to do this test is uglier, but actually works:
[Test]
public void ExceptionThrownByVerifier() {
doSomeSetup();
doSomeProcessing();
try {
callSomethingThatThrowsTheException();
fail("Expected Exception");
}
catch (ExceptionType e) {
//expected
}
}
If doSomeSetup() throws an Exception, then the test will fail, and tell me why.
One of the nicest classes in C# is the StringFormatter. I’ve always wanted one in Java. And I just found where they got the idea from. As with the rest of C#: Java. In fact java.text.MessageFormat. D’oh
try {
...
} catch (FileNotFoundException e) {
System.err.println(
MessageFormat.format(
"Could not find file {0} ({1})",
new Object[] {file, e.getMessage()} ) );
}
This slashdot article about generics points to JSR-201. This contains some concrete proposals for enumerations, autoboxing, enhanced for loop and static import. I hadn’t seen these before, and they make for interesting reading.
The Register
Gotta love it.
Ah the joys of webmin. If you run a Unix server and haven’t yet discovered it, ake a look. A two second install gives you instant access to a web control panel for your server, with things like one-click web analysis reports and emailing you when a service goes down. Really really cool.