JUnit ソースリーディング中...(2)
うーん、理解しにくい。
/** * A convenience method to run this test, collecting the results with a * default TestResult object. * * @see TestResult */ public TestResult run() { TestResult result= createResult(); run(result); return result; } /** * Runs the test case and collects the results in TestResult. */ public void run(TestResult result) { result.run(this); }
TestCace#run が呼ばれると、内部でTestResultを引数にrunメソッドを呼ぶのだが、そのrunメソッドでは、自身を引数に、そのTestResultのrunメソッドを呼んでいる。
うおー。わけわかんねー。役割を考えて、じっくり考えればそのうちわかるかな。
あと、Protectable。TestResultのrunメソッドでは引数のTestCaseのrunメソッドを呼ぶのではなく、Protectableにラップして呼んでいる。Protectableのprotectメソッドはthrows Throwableしているが、ラップされているTestCase#runBareもthrows Throwableしているのである。
まったく同じことを
http://tech.groups.yahoo.com/group/junit/message/10757
の人も考えていて、答えている人もいるのだけど、よくわからん。
まだまだJava初心者ということがよくわかった。