Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/resources/META-INF/jqassistant-rules/junit4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,15 @@
]]></cypher>
</concept>

<concept id="junit4:RunWith">
<description>Labels all classes annotated with org.junit.runner.RunWith with "Junit4" and "Test".</description>
<cypher><![CDATA[
MATCH
(source:Type)-[r:ANNOTATED_BY]->(target)-[x:OF_TYPE]-(y {fqn:"org.junit.runner.RunWith"})
SET
source:Junit4:Test
RETURN
source
]]></cypher>
</concept>
</jqa:jqassistant-rules>
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
import com.buschmais.jqassistant.core.rule.api.model.RuleException;
import com.buschmais.jqassistant.plugin.common.test.scanner.MapBuilder;
import com.buschmais.jqassistant.plugin.java.api.model.MethodDescriptor;
import com.buschmais.jqassistant.plugin.junit.test.set.junit4.Assertions4Junit4;
import com.buschmais.jqassistant.plugin.junit.test.set.junit4.IgnoredTest;
import com.buschmais.jqassistant.plugin.junit.test.set.junit4.TestClass;
import com.buschmais.jqassistant.plugin.junit.test.set.junit4.TestSuite;
import com.buschmais.jqassistant.plugin.junit.test.set.junit4.*;

import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.jupiter.api.Test;

import static com.buschmais.jqassistant.core.report.api.model.Result.Status.SUCCESS;
Expand Down Expand Up @@ -235,6 +233,19 @@ public void afterClassMethod() throws Exception {
store.commitTransaction();
}

/**
* Verifies the concept "junit4:RunWith".
*/
@Test
public void runWith() throws Exception {
scanClasses(EnclosedTestClass.class);
assertThat(applyConcept("junit4:RunWith").getStatus(), equalTo(SUCCESS));
store.beginTransaction();
List<Object> methods = query("match (m:Junit4:Test {name:\"EnclosedTestClass\"}) return m").getColumn("m");
assertThat(methods, hasItem(typeDescriptor(EnclosedTestClass.class)));
store.commitTransaction();
}

/**
* Verifies the group "junit4:default".
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.buschmais.jqassistant.plugin.junit.test.set.junit4;

import org.junit.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;

/**
* A JUnit4 test classes using enclosed test classes.
*/
@RunWith(Enclosed.class)
public class EnclosedTestClass {

public static class FirstTest {
@Test
public void testMethod() {
}
}

public static class SecondTest {
@Test
public void testMethod() {
}
}

}