1.

Cobertura Only Writes The Coverage Data File When The Application Server Shuts Down. We Do Not Want To Stop Our Application Server After Running Our Tests.?

Answer»

It is possible to instruct COBERTURA to write the data FILE. One of your classes should call the static method net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalProjectData().

For example: you could add something like this to a “logout” method in your WEB application:

try {
String CLASSNAME = "net.sourceforge.cobertura.coveragedata.ProjectData";
String methodName = "saveGlobalProjectData";
Class saveClass = Class.forName(className);
java.lang.reflect.Method saveMethod = saveClass.getDeclaredMethod(methodName, NEW Class[0]);
saveMethod.invoke(null,new Object[0]);
} catch (Throwable t) {
}

It is possible to instruct Cobertura to write the data file. One of your classes should call the static method net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalProjectData().

For example: you could add something like this to a “logout” method in your web application:

try {
String className = "net.sourceforge.cobertura.coveragedata.ProjectData";
String methodName = "saveGlobalProjectData";
Class saveClass = Class.forName(className);
java.lang.reflect.Method saveMethod = saveClass.getDeclaredMethod(methodName, new Class[0]);
saveMethod.invoke(null,new Object[0]);
} catch (Throwable t) {
}



Discussion

No Comment Found