Search in sources :

Example 6 with ClassUnderTest

use of org.kanonizo.framework.objects.ClassUnderTest in project kanonizo by kanonizo.

the class ScytheInstrumenter method collectBranches.

private Set<org.kanonizo.framework.objects.Branch> collectBranches(TestCase testCase) {
    Set<org.kanonizo.framework.objects.Branch> covered = new HashSet<>();
    List<Class<?>> changedClasses = ClassAnalyzer.getChangedClasses();
    for (Class<?> cl : changedClasses) {
        if (ClassStore.get(cl.getName()) != null) {
            ClassUnderTest parent = ClassStore.get(cl.getName());
            List<com.scythe.instrumenter.instrumentation.objectrepresentation.Branch> branches = ClassAnalyzer.getCoverableBranches(cl.getName());
            Set<com.scythe.instrumenter.instrumentation.objectrepresentation.Branch> branchesCovered = branches.stream().filter(branch -> branch.getHits() > 0).collect(Collectors.toSet());
            Set<Branch> kanBranches = branchesCovered.stream().map(branch -> BranchStore.with(parent, branch.getLineNumber(), branch.getGoalId())).collect(Collectors.toSet());
            covered.addAll(kanBranches);
        }
    }
    return covered;
}
Also used : Arrays(java.util.Arrays) ClassStore(org.kanonizo.framework.ClassStore) LineStore(org.kanonizo.framework.objects.LineStore) TestSuite(org.kanonizo.framework.objects.TestSuite) Branch(org.kanonizo.framework.objects.Branch) HashMap(java.util.HashMap) Framework(org.kanonizo.Framework) Parameter(com.scythe.instrumenter.InstrumentationProperties.Parameter) InstrumentationProperties(com.scythe.instrumenter.InstrumentationProperties) GsonBuilder(com.google.gson.GsonBuilder) TypeAdapter(com.google.gson.TypeAdapter) JsonReader(com.google.gson.stream.JsonReader) BufferedOutputStream(java.io.BufferedOutputStream) ArrayList(java.util.ArrayList) ClassUnderTest(org.kanonizo.framework.objects.ClassUnderTest) TestCase(org.kanonizo.framework.objects.TestCase) ClassReplacementTransformer(com.scythe.instrumenter.instrumentation.ClassReplacementTransformer) HashSet(java.util.HashSet) HashSetCollector(org.kanonizo.util.HashSetCollector) Gson(com.google.gson.Gson) Instrumenter(org.kanonizo.framework.instrumentation.Instrumenter) Map(java.util.Map) Goal(org.kanonizo.framework.objects.Goal) JsonWriter(com.google.gson.stream.JsonWriter) InstrumentingClassLoader(com.scythe.instrumenter.instrumentation.InstrumentingClassLoader) Iterator(java.util.Iterator) FileOutputStream(java.io.FileOutputStream) Set(java.util.Set) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) List(java.util.List) BranchStore(org.kanonizo.framework.objects.BranchStore) Util(org.kanonizo.util.Util) Logger(org.apache.logging.log4j.Logger) SystemUnderTest(org.kanonizo.framework.objects.SystemUnderTest) ClassAnalyzer(com.scythe.instrumenter.analysis.ClassAnalyzer) Line(org.kanonizo.framework.objects.Line) FileReader(java.io.FileReader) Comparator(java.util.Comparator) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) TestCaseStore(org.kanonizo.framework.TestCaseStore) Branch(org.kanonizo.framework.objects.Branch) HashSet(java.util.HashSet) ClassUnderTest(org.kanonizo.framework.objects.ClassUnderTest)

Aggregations

ClassUnderTest (org.kanonizo.framework.objects.ClassUnderTest)6 TestCase (org.kanonizo.framework.objects.TestCase)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5 Gson (com.google.gson.Gson)4 Parameter (com.scythe.instrumenter.InstrumentationProperties.Parameter)4 File (java.io.File)4 FileReader (java.io.FileReader)4 IOException (java.io.IOException)4 Collections (java.util.Collections)4 Comparator (java.util.Comparator)4 Iterator (java.util.Iterator)4 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 Framework (org.kanonizo.Framework)4 Instrumenter (org.kanonizo.framework.instrumentation.Instrumenter)4 SystemUnderTest (org.kanonizo.framework.objects.SystemUnderTest)4 Util (org.kanonizo.util.Util)4