"Matching Programming" Activity: Java File Writer

I just read the article Matching Programming . There are exercises at the end of the page. A few snippets of code that are cases of "coincident programming." But I can not understand the error in this part:

This code comes from a general purpose Java trace set. The function writes a line to the log file. This passes it to unit test, but does not work when one of the web developers uses it. What coincidence does he rely on?

  public static void debug(String s) throws IOException {
    FileWriter fw = new FileWriter("debug.log", true);
    fw.write(s);
    fw.flush();
    fw.close();
  }

What's bad about it?

+5
source share
2 answers

, debug.log, . , - , , .

A unit test , ( ). , unit test .

+10

. , . , , . , classpath (, eclipse), .?

0

All Articles