java - Counting number of lines in test classes -


i'm developing tool recognizes test classes , counts number of lines in classes. tool count lines of business code , compare both results, here code:

    (file f : list) {         if (f.isdirectory()) {             walk(f.getabsolutepath());         }          if (f.getname().endswith(".java")) {              system.out.println("file:" + f.getname());             countfiles++;              scanner testscanner = new scanner(f);             while (testscanner.hasnextline()) {                  string test = testscanner.nextline();                 if (test.contains("org.junit") || test.contains("org.mockito")) {                     system.out.println("this test class");                     testcounter++;                      break;                 }             }             scanner sc2 = new scanner(f);              while (sc2.hasnextline()) {                  count++; 

counting business code using (count++) working perfectly, counting number of code in test classes not working using (testcounter++) returning number of test classes rather number of lines in classes! can ?

thanks

assuming wanting count number of lines contain either org.junit or org.mockito

then want do

       while (testscanner.hasnextline()) {              string test = testscanner.nextline();             if (test.contains("org.junit") || test.contains("org.mockito"))              {                 hastestlines = true;             }             count++;         }          if (hastestlines) {              system.out.println(string.format ("there %d lines in file %s had org.junit||org.mockito",                                      count, f.getname());         }         else {              system.out.println(string.format ("there %d lines in file %s did not have org.junit||org.mockito",                                      count, f.getname());        } 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -