Comments (5)
It should work without any issues, please read: https://github.com/cobertura/cobertura/wiki/FAQ and search for the Tomcat section.
from cobertura.
Haha, works. I noticed there is a way to force the cobertura ser file to be written while the server is on, is there a way to clear the cobertura data so I don't have to restart tomcat to get a fresh coverage?
from cobertura.
There is no safe way to clear the cobertura data. Cobertura data does not get written until jvm shutdown hooks are executed.
There might be a few ways, however that could involve a lot of hacking which I would strongly advise against. However here is the hack. For each class that gets instrumented, we add a method
public static int[] __cobertura_get_and_reset_counters() {...}
which can be called using reflection. However this will require that you scan every single class loaded in the jvm to see if it contains the method above and invoke it with reflection.
String className = "Name.Of.Instrumented.Class";
String methodName = "__cobertura_get_and_reset_counters";
Class saveClass = Class.forName(className);
java.lang.reflect.Method saveMethod = saveClass.getDeclaredMethod(
methodName, new Class[0]);
saveMethod.invoke(null, new Object[0]);
Also a try-catch block would need to go around the invoke call just in case the method does not exist. If you can provide a use case where resetting the count could be useful, I could write something for the FlushCoberturaServlet to allow for resetting of all coverage information.
from cobertura.
We'll we run automated tests and when I do a full run I would love to do a reset on the instrumented files, run tests, dump ser, create report. I'm not to fond of using scripting to do the work of rebooting the server as it leaves the automated tests system dependent.
from cobertura.
I'm not sure I understand the process you are doing. Are you trying to do the following:
- Reset instrumented files
- run tests
- dump ser
- create report
Step 1 is not necessary because cobertura when it initially starts it is at 0 everything. Step 3 can be achieved using the coberturaFlush.war file where you can flush cobertura data at anytime. Also see the FAQ (last part) on how to create your own cobertura flushing part (e.x. when logout button is pressed). We also have a test unit (WebAppFunctionalTest.java) that flushes cobertura information while (in our case a jetty servlet) is still running.
from cobertura.
Related Issues (20)
- SomeUtilsClass does not appear in the cobertura report
- Cobertura 2.7 + Tycho JDT <= 0.15.0 causes lines to be not covered
- Method partially covered but missing from Metrics and lines aren't highlighted in File(s) sections
- How to reset minimum stability once it has reached a certain level following autoUpdateStability true? HOT 1
- Cobertura report is not getting generated for few classes having java 8, though few classes containing same Java 8 is getting included in reports
- Visual Studio Code Coverage file (.coverage) support
- When can we expect latest releases for Cobertura which is compatible with Java 8 and higher versions HOT 4
- cobertura-2.1.1 throws InvocationTargetException worked in cobertura-1.9.4.1
- I hava a question. How to convert/transform Cobertura.xml(codecoverage report) to junit
- java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/LightClassmapListener
- log4j vulnerability in cobertura 1.9.4.1
- What is "coverage-04.dtd" HOT 1
- after upgrade of jenkins and cobertura plugin build fails
- How to merge two cobertura xmls? HOT 1
- Build Fails Despite 100% Coverage
- Would anyone from the Cobertura community be available for a quick code review?
- Cobertura caching deleted files
- In a multi-process scenario, coverage data is abnormal.
- Cobertura report generation is stuck
- cobertura coverage report give much higher Cyclomatic Complexity score for given Method then Visual Studio 2022 Code Metrics Results
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cobertura.