001 /** 002 * www.jcoverage.com 003 * Copyright (C)2003 jcoverage ltd. 004 * 005 * This file is part of jcoverage. 006 * 007 * jcoverage is free software; you can redistribute it and/or modify 008 * it under the terms of the GNU General Public License as published 009 * by the Free Software Foundation; either version 2 of the License, 010 * or (at your option) any later version. 011 * 012 * jcoverage is distributed in the hope that it will be useful, but 013 * WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * General Public License for more details. 016 * 017 * You should have received a copy of the GNU General Public License 018 * along with jcoverage; if not, write to the Free Software 019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 020 * USA 021 * 022 */ 023 package com.jcoverage.coverage; 024 025 import java.io.Serializable; 026 import java.util.Map; 027 import java.util.Set; 028 029 /** 030 * Instrumentation information is typically serialized to a file. An 031 * instance of this class records coverage information for a single 032 * class that has been instrumented. 033 */ 034 public interface Instrumentation extends Serializable { 035 /** 036 * default file name used to write instrumentation information. 037 */ 038 String FILE_NAME="jcoverage.ser"; 039 040 /** 041 * Increment the number of hits for a particular line of code. 042 * @param lineNumber the line of code to increment the number of hits. 043 */ 044 void touch(int lineNumber); 045 046 /** 047 * @return a sorted coverage mapping from source line to number of 048 * hits. 049 */ 050 Map getCoverage(); 051 052 /** 053 * @return the number of hits a particular line of code has. 054 * @param lineNumber the source code line number. 055 */ 056 long getCoverage(int lineNumber); 057 058 /** 059 * Merge some existing instrumentation with this instrumentation. 060 * @param instrumentation some existing instrumentation. 061 */ 062 void merge(Instrumentation instrumentation); 063 064 /** 065 * @return the set of valid source line numbers 066 */ 067 Set getSourceLineNumbers(); 068 069 /** 070 * @return the line coverage rate for the class 071 */ 072 double getLineCoverageRate(); 073 074 /** 075 * @return the branch coverage rate for the class 076 */ 077 double getBranchCoverageRate(); 078 079 /** 080 * @return the line coverage rate for particular method 081 */ 082 double getLineCoverageRate(String methodNameAndSignature); 083 084 /** 085 * @return the branch coverage rate for a particular method 086 */ 087 double getBranchCoverageRate(String methodNameAndSignature); 088 089 /** 090 * @return the source file name. 091 */ 092 String getSourceFileName(); 093 094 /** 095 * @return the method name and signature of each method found in the 096 * class represented by this instrumentation. 097 */ 098 Set getMethodNamesAndSignatures(); 099 }