java - Hogyan kezdjem el a kódlefedettség-eszköz írását?

original title: "java - How to get started writing a code coverage tool?"


Looking for books or other references that discuss actually how to write a code coverage tool in Java; some of the various techniques or tricks - source vs. byte code instrumentation.

This is for a scripting language that generates Java byte code under the hood.

Olyan könyveket vagy más referenciákat keres, amelyek megvitatják a kódlefedettség-eszköz Java nyelvben való tényleges írásának módját; a különböző technikák vagy trükkök némelyike - forrás vs bájt kódmérés. Ez ...

Ez az összefoglalás a fordítás után. Ha meg szeretné tekinteni a teljes fordítást, kattintson a "fordítás" ikonra

Minden válasz
  • Translate

    Does your scripting language generate bytecode? Does it generate debug metadata? If so, bytecode instrumentation is probably the way to go. In fact existing tools will probably work (perhaps with minimal modification).

    The typical problem with such tools that they are written to work with Java and assume that a class corresponds to a file com/foo/ Unwinding that assumption can be tedious.

    EMMA is a ClassLoader that does byte-code re-writing for code-coverage collection in Java. The coding style is a little funky, but I recommend reading source code for some ideas.

    If your scripting language is interpreted then you will need a higher-level class loader (at a source level) that hooks into the interpreter.

  • Gilbert Lee

    You can also get the source from a Open Source code coverage tool and learn from it.

  • Adelaide Lee

    Thxm, Mc! is another one. Excellent documentation on byte code instrumentation, but nothing "directly" aimed at writing a coverage tool - just some hints or ideas.

  • Translate

    You might also want to use something like BCEL to analyse which lines of source actually exist in the byte-code. You don't want to report that things like blank lines and comments haven't been covered.

  • Translate

    If you're talking about ColdFusion (which I assume you are from the tags) then I'm not sure this is doable but I may be very wrong here...

    IIRC, When CF compiles it essentially compiles into a interpreted form of the CFML as a plain old java source file, this is then compiled into the class. Therefore, any instrumentation that you may have will apply to the intermediary version rather than the CFML itself.

    Saying that though, Adobe have got the CF debugger now which can step though code, so please prove me wrong - I'd love code coverage in CFML.