Creating Your Own Code Coverage Plugin

This topic describes how to create a code coverage plugin. You should be familiar with the Silk Central baseline concept. In Silk Central, a baseline is required before each run. A baseline includes all namespaces/packages/classes/methods in the test application.

Note: The Silk Central API requires an XML file to be returned for code coverage runs. This means that if your code coverage tool stores its code coverage information in a database, you will need to take additional steps to retrieve the data.
Note: Multiple execution servers running tests against the same Code Analysis Framework at the same time is not supported.
  1. Add the library scc.jar to your classpath as it contains the interfaces that must be extended. The JAR file can be found in the lib directory of the Silk Central installation directory.
  2. Add the following two import statements:
    import com.segue.scc.published.api.codeanalysis.CodeAnalysisProfile;
    import com.segue.scc.published.api.codeanalysis.CodeAnalysisProfileException;
    import com.segue.scc.published.api.codeanalysis.CodeAnalysisResult;
  3. Create a class that implements CodeAnalysisProfile.
  4. Add all the required methods from the code coverage interface which are listed in the following steps. You can either refer to the Sample Interface Class for its definition and manually implement the methods or you can copy and paste the topic Sample Profile Class which has the imports and method definitions in it for you.
    Note: The methods in the following steps that you will write are actually called by Silk Central when it needs them. This means that you will not be directly calling them.
  5. Code getBaseline. This method should return an XML file that contains all the namespaces/packages/classes/methods in the application. See the Sample XML Data topic file for the format of the file. You should validate the XML using the sample XSD file. See the Code Coverage XSD topic for the XSD.

    This function is called before starting coverage and is triggered by the Silk Central execution server starting a test run to start code analysis and return all of the objects to be covered. The output needs to be converted into XML using the format specified in the XML schema included in the CA-Framework installation folder.

  6. Code startCoverage. This call should tell your code coverage tool to start collecting data. Return true if it starts.

    This is called by the Silk Central Code Coverage Framework after the getBaseLine() method is complete. This is where you should start your code coverage tool collecting code coverage data.

  7. Code stopCoverage. This call should tell your code coverage tool to stop collecting data. Return true for success.

    This is called after startCoverage and is triggered by the Silk Central execution server finishing a test run to stop code analysis.

  8. Code getCoverage. This returns an XML file with collected data from between the startCoverage and stopCoverage methods. See the Sample XML Data topic for the format of the file. You should validate the XML using the sample XSD file. See the Code Coverage XSD topic for the XSD.

    This function is called after stopCoverage() and returns all the coverage data collected. The output needs to be converted into XML using the specified in the XML schema.

  9. Code GetName. This should provide the name that will be used to refer to the code coverage tool. For example, this value will be used as one of the values in the Code Analysis Profile list on the Edit Code Analysis Settings dialog box.

    This is called first by the Silk Central Code Coverage framework. The name of the plug-in is displayed in the code coverage list in Silk Central.

  10. Build the plug-in into a jar and put the jar into a zip file.
  11. Deploy your plug-in to the following locations:
    • In the Plugins directory of Silk Central's installation folder.
    • In the Plugins directory of the CA-Framework installation.