META-INF.jqassistant-rules.test-impact-analysis.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jqassistant-test-impact-analysis-plugin Show documentation
Show all versions of jqassistant-test-impact-analysis-plugin Show documentation
The jQAssistant plugin for test impact analysis creates test suites for Maven based on changes in the version control system.
<jqa:jqassistant-rules xmlns:jqa="http://www.buschmais.com/jqassistant/core/rule/schema/v1.3"> <concept id="test-impact-analysis:FilesChangedByLastGitCommit" severity="info"> <requiresConcept refId="git:CurrentBranch" /> <description>Adds a label 'Changed' to all Git files that have been changed in the last Git commit.</description> <cypher><![CDATA[ MATCH (:Branch:Current)-[:HAS_HEAD]->(:Commit)-[:CONTAINS_CHANGE]->()-[:MODIFIES]->(sourceFile:File) WHERE sourceFile.relativePath ends with ".java" SET sourceFile:Changed ]]></cypher> </concept> <concept id="test-impact-analysis:TypesChangedByLastGitCommit" severity="info"> <requiresConcept refId="test-impact-analysis:FilesChangedByLastGitCommit" /> <description>Adds a label 'Changed' to all Java types that have been changed in the last Git commit.</description> <cypher><![CDATA[ MATCH (sourceFile:Git:File:Changed) WHERE sourceFile.relativePath ends with ".java" WITH sourceFile MATCH (package:Package)-[:CONTAINS]->(changedType:Type) WHERE sourceFile.relativePath ends with (package.fileName + "/" + changedType.sourceFileName) SET changedType:Changed RETURN changedType ]]></cypher> </concept> <concept id="test-impact-analysis:TestsAffectedByLastGitCommit" severity="info"> <requiresConcept refId="test-impact-analysis:TypesChangedByLastGitCommit" /> <requiresConcept refId="junit4:TestClass" /> <description>Adds a label 'Affected' to all test classes having a dependency to Java types which were changed in the last Git commit.</description> <cypher><![CDATA[ MATCH hierarchy=shortestPath((changedType:Type:Changed)-[:EXTENDS|IMPLEMENTS*0..]-(type:Type)) WITH type, hierarchy WHERE all(t in nodes(hierarchy) WHERE (:Artifact)-[:CONTAINS]->(t)) WITH type MATCH (testArtifact:Artifact)-[:CONTAINS]->(testPackage:Package)-[:CONTAINS]->(test:Class), (test)-[:EXTENDS|IMPLEMENTS*0..]->(:Test:Class)-[:DEPENDS_ON*0..1]->(type:Type) WHERE NOT (exists(test.abstract) and test.abstract) SET test:Affected RETURN testArtifact as Artifact, collect(distinct test) as Tests ]]></cypher> </concept> <concept id="test-impact-analysis:SurefireSuiteForLastGitCommit" severity="info"> <requiresConcept refId="test-impact-analysis:TestsAffectedByLastGitCommit" /> <description>Reports all test classes affected by the last Git commit.</description> <cypher><![CDATA[ MATCH (:Maven:Project)-[:CREATES]->(artifact:Artifact) OPTIONAL MATCH (artifact)-[:CONTAINS]->(test:Affected:Test) RETURN artifact as Artifact, collect(test) as Tests ]]></cypher> <report type="surefire-suite" /> </concept> <concept id="test-impact-analysis:GitBaseCommit"> <description>Adds a label 'Base' to all commits with more than one child commits (i.e. commits where a branch is split off).</description> <cypher><![CDATA[ MATCH (child:Commit)-[p:HAS_PARENT]->(branchBase:Commit) WITH branchBase, count(child) as children WHERE children > 1 SET branchBase:Base RETURN branchBase as Base, children as Children ]]></cypher> </concept> <concept id="test-impact-analysis:FilesChangedByCommitsInCurrentGitBranch" severity="info"> <requiresConcept refId="git:CurrentBranch" /> <requiresConcept refId="test-impact-analysis:GitBaseCommit" /> <requiresParameter name="testImpactAnalysisGitBaseBranch" type="String" defaultValue="heads/master"/> <description>Adds a label 'Changed' to Git files that changed in the current branch.</description> <cypher><![CDATA[ MATCH (branch:Branch:Current)-[:HAS_HEAD]->(branchHead:Commit), branchHistory=shortestPath((base:Commit:Base)<-[:HAS_PARENT*]-(branchHead)) WHERE branchHead <> base WITH base, branchHistory MATCH (baseBranch:Branch)-[:HAS_HEAD]->(baseHead:Commit), baseHistory=shortestPath((base)<-[:HAS_PARENT*]-(baseHead)) WHERE baseBranch.name ends with {testImpactAnalysisGitBaseBranch} and baseHead <> base WITH branchHistory LIMIT 1 UNWIND nodes(branchHistory) as commit WITH commit MATCH (commit)-[:CONTAINS_CHANGE]->()-[:MODIFIES]->(sourceFile:File) SET sourceFile:Changed RETURN commit.sha, collect(sourceFile.relativePath) ]]></cypher> </concept> <concept id="test-impact-analysis:TypesChangedByCurrentGitBranch" severity="info"> <requiresConcept refId="test-impact-analysis:FilesChangedByCommitsInCurrentGitBranch" /> <requiresConcept refId="junit4:TestClass" /> <description>Adds a label 'Changed' to Java types that changed in the current branch.</description> <cypher><![CDATA[ MATCH (sourceFile:File:Changed) WHERE sourceFile.relativePath ends with ".java" WITH sourceFile MATCH (package:Package)-[:CONTAINS]->(changedType:Type) WHERE sourceFile.relativePath ends with (package.fileName + "/" + changedType.sourceFileName) SET changedType:Changed RETURN changedType ]]></cypher> </concept> <concept id="test-impact-analysis:TestsAffectedByCurrentGitBranch" severity="info"> <requiresConcept refId="test-impact-analysis:TypesChangedByCurrentGitBranch" /> <requiresConcept refId="junit4:TestClass" /> <description>Adds a label 'Affected' to all test classes having a dependency to Java types which were changed by commits in the current Git branch.</description> <cypher><![CDATA[ MATCH hierarchy=shortestPath((changedType:Type:Changed)-[:EXTENDS|IMPLEMENTS*0..]-(type:Type)) WITH type, hierarchy WHERE all(t in nodes(hierarchy) WHERE (:Artifact)-[:CONTAINS]->(t)) WITH type MATCH (testArtifact:Artifact)-[:CONTAINS]->(testPackage:Package)-[:CONTAINS]->(test:Class), (test)-[:EXTENDS|IMPLEMENTS*0..]->(:Test:Class)-[:DEPENDS_ON*0..1]->(type:Type) WHERE NOT (exists(test.abstract) and test.abstract) SET test:Affected RETURN testArtifact as Artifact, collect(distinct test) as Tests ]]></cypher> </concept> <concept id="test-impact-analysis:SurefireSuiteForCurrentBranch" severity="info"> <requiresConcept refId="test-impact-analysis:TestsAffectedByCurrentGitBranch" /> <description>Reports all test classes affected by commits in the current Git branch.</description> <cypher><![CDATA[ MATCH (:Maven:Project)-[:CREATES]->(artifact:Artifact) OPTIONAL MATCH (artifact)-[:CONTAINS]->(test:Affected:Test) RETURN artifact as Artifact, collect(test) as Tests ]]></cypher> <report type="surefire-suite" /> </concept> <constraint id="test-impact-analysis:TestGapForLastGitCommit"> <requiresConcept refId="test-impact-analysis:TypesChangedByLastGitCommit" /> <requiresConcept refId="junit4:TestMethod" /> <requiresParameter name="testImpactAnalysisGapMethodVisibility" type="String" defaultValue="public"/> <description>Public methods of Java types that changed in the last Git commit which are not covered by test methods (experimental).</description> <cypher><![CDATA[ WITH split({testImpactAnalysisGapMethodVisibility},",") as visibilities MATCH (type:Changed)-[:DECLARES]->(method:Method) WHERE not method:Constructor and method.visibility in visibilities and not (:Test:Method)-[:INVOKES]->(method) WITH type, collect(method) as Methods MATCH (artifact:Artifact)-[:CONTAINS]->(type) RETURN artifact as Artifact, type as Type, Methods ]]></cypher> </constraint> <constraint id="test-impact-analysis:TestGapForCurrentGitBranch"> <requiresConcept refId="test-impact-analysis:TypesChangedByCurrentGitBranch" /> <requiresConcept refId="junit4:TestMethod" /> <requiresParameter name="testImpactAnalysisGapMethodVisibility" type="String" defaultValue="public"/> <description>Public methods of Java types that changed in the current Git branch which are not covered by test methods (experimental).</description> <cypher><![CDATA[ WITH split({testImpactAnalysisGapMethodVisibility},",") as visibilities MATCH (type:Changed)-[:DECLARES]->(method:Method) WHERE not method:Constructor and method.visibility in visibilities and not (:Test:Method)-[:INVOKES]->(method) WITH type, collect(method) as Methods MATCH (artifact:Artifact)-[:CONTAINS]->(type) RETURN artifact as Artifact, type as Type, Methods ]]></cypher> </constraint> </jqa:jqassistant-rules>