Search in sources :

Example 1 with FileSource

use of org.junit.platform.engine.support.descriptor.FileSource in project intellij-community by JetBrains.

the class JUnit5TestExecutionListener method getLocationHintValue.

static String getLocationHintValue(TestSource testSource, boolean isTest) {
    if (testSource instanceof CompositeTestSource) {
        CompositeTestSource compositeTestSource = ((CompositeTestSource) testSource);
        for (TestSource sourceFromComposite : compositeTestSource.getSources()) {
            String locationHintValue = getLocationHintValue(sourceFromComposite, isTest);
            if (!NO_LOCATION_HINT_VALUE.equals(locationHintValue)) {
                return locationHintValue;
            }
        }
        return NO_LOCATION_HINT_VALUE;
    }
    if (testSource instanceof FileSource) {
        FileSource fileSource = (FileSource) testSource;
        File file = fileSource.getFile();
        String line = fileSource.getPosition().map(position -> ":" + position.getLine()).orElse("");
        return "file://" + file.getAbsolutePath() + line;
    }
    if (testSource instanceof MethodSource) {
        MethodSource methodSource = (MethodSource) testSource;
        return javaLocation(methodSource.getClassName(), methodSource.getMethodName(), isTest);
    }
    if (testSource instanceof ClassSource) {
        String className = ((ClassSource) testSource).getClassName();
        return javaLocation(className, null, isTest);
    }
    return NO_LOCATION_HINT_VALUE;
}
Also used : ReportEntry(org.junit.platform.engine.reporting.ReportEntry) TestPlan(org.junit.platform.launcher.TestPlan) JUnit4TestListener(com.intellij.junit4.JUnit4TestListener) CompositeTestSource(org.junit.platform.engine.support.descriptor.CompositeTestSource) TestExecutionResult(org.junit.platform.engine.TestExecutionResult) ClassSource(org.junit.platform.engine.support.descriptor.ClassSource) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) AssertionFailedError(org.opentest4j.AssertionFailedError) Map(java.util.Map) ExpectedPatterns(com.intellij.junit4.ExpectedPatterns) MapSerializerUtil(com.intellij.rt.execution.junit.MapSerializerUtil) MethodSource(org.junit.platform.engine.support.descriptor.MethodSource) PrintStream(java.io.PrintStream) PrintWriter(java.io.PrintWriter) ComparisonFailureData(com.intellij.rt.execution.junit.ComparisonFailureData) FileSource(org.junit.platform.engine.support.descriptor.FileSource) MultipleFailuresError(org.opentest4j.MultipleFailuresError) StringWriter(java.io.StringWriter) TestSource(org.junit.platform.engine.TestSource) Set(java.util.Set) File(java.io.File) TestIdentifier(org.junit.platform.launcher.TestIdentifier) ValueWrapper(org.opentest4j.ValueWrapper) TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) CompositeTestSource(org.junit.platform.engine.support.descriptor.CompositeTestSource) CompositeTestSource(org.junit.platform.engine.support.descriptor.CompositeTestSource) TestSource(org.junit.platform.engine.TestSource) FileSource(org.junit.platform.engine.support.descriptor.FileSource) MethodSource(org.junit.platform.engine.support.descriptor.MethodSource) File(java.io.File) ClassSource(org.junit.platform.engine.support.descriptor.ClassSource)

Aggregations

ExpectedPatterns (com.intellij.junit4.ExpectedPatterns)1 JUnit4TestListener (com.intellij.junit4.JUnit4TestListener)1 ComparisonFailureData (com.intellij.rt.execution.junit.ComparisonFailureData)1 MapSerializerUtil (com.intellij.rt.execution.junit.MapSerializerUtil)1 File (java.io.File)1 PrintStream (java.io.PrintStream)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 TestExecutionResult (org.junit.platform.engine.TestExecutionResult)1 TestSource (org.junit.platform.engine.TestSource)1 ReportEntry (org.junit.platform.engine.reporting.ReportEntry)1 ClassSource (org.junit.platform.engine.support.descriptor.ClassSource)1 CompositeTestSource (org.junit.platform.engine.support.descriptor.CompositeTestSource)1 FileSource (org.junit.platform.engine.support.descriptor.FileSource)1 MethodSource (org.junit.platform.engine.support.descriptor.MethodSource)1 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)1