Search in sources :

Example 1 with MethodTestDescriptor

use of org.junit.jupiter.engine.descriptor.MethodTestDescriptor in project intellij-community by JetBrains.

the class JUnit5EventsTest method multipleFailures.

@Test
void multipleFailures() throws Exception {
    TestDescriptor testDescriptor = new MethodTestDescriptor(UniqueId.forEngine("engine"), TestClass.class, TestClass.class.getDeclaredMethod("test1"));
    TestIdentifier identifier = TestIdentifier.from(testDescriptor);
    myExecutionListener.executionStarted(identifier);
    MultipleFailuresError multipleFailuresError = new MultipleFailuresError("2 errors");
    multipleFailuresError.addFailure(new AssertionFailedError("message1", "expected1", "actual1"));
    multipleFailuresError.addFailure(new AssertionFailedError("message2", "expected2", "actual2"));
    myExecutionListener.executionFinished(identifier, TestExecutionResult.failed(multipleFailuresError));
    Assertions.assertEquals("##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testStarted id='|[engine:engine|]' name='test1()' locationHint='java:test://com.intellij.junit5.JUnit5EventsTest$TestClass.test1']\n" + "\n" + "##teamcity[testFailed name='test1()' id='|[engine:engine|]' details='' message='' expected='expected1' actual='actual1']\n" + "\n" + "##teamcity[testFailed name='test1()' id='|[engine:engine|]' details='' message='' expected='expected2' actual='actual2']\n" + "\n" + "##teamcity[testFailed name='test1()' id='|[engine:engine|]' details='TRACE' message='2 errors (2 failures)|n\tmessage1|n\tmessage2']\n" + "\n" + "##teamcity[testFinished id='|[engine:engine|]' name='test1()']\n", StringUtil.convertLineSeparators(myBuf.toString()));
}
Also used : MethodTestDescriptor(org.junit.jupiter.engine.descriptor.MethodTestDescriptor) TestIdentifier(org.junit.platform.launcher.TestIdentifier) AssertionFailedError(org.opentest4j.AssertionFailedError) MethodTestDescriptor(org.junit.jupiter.engine.descriptor.MethodTestDescriptor) TestFactoryTestDescriptor(org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor) ClassTestDescriptor(org.junit.jupiter.engine.descriptor.ClassTestDescriptor) TestDescriptor(org.junit.platform.engine.TestDescriptor) MultipleFailuresError(org.opentest4j.MultipleFailuresError)

Example 2 with MethodTestDescriptor

use of org.junit.jupiter.engine.descriptor.MethodTestDescriptor in project intellij-community by JetBrains.

the class JUnit5NavigationTest method methodNavigation.

@Test
void methodNavigation() throws Exception {
    UniqueId uniqueId = UniqueId.parse("[class:JUnit5NavigationTest]/[method:methodNavigation]");
    MethodTestDescriptor methodTestDescriptor = new MethodTestDescriptor(uniqueId, JUnit5NavigationTest.class, JUnit5NavigationTest.class.getDeclaredMethod("methodNavigation"));
    TestIdentifier testIdentifier = TestIdentifier.from(methodTestDescriptor);
    Assertions.assertEquals(JUnit5NavigationTest.class.getName(), JUnit5TestExecutionListener.getClassName(testIdentifier));
    Assertions.assertEquals("methodNavigation", JUnit5TestExecutionListener.getMethodName(testIdentifier));
//Assertions.assertEquals("methodNavigation", testIdentifier.getDisplayName()); todo methodNavigation()
}
Also used : UniqueId(org.junit.platform.engine.UniqueId) MethodTestDescriptor(org.junit.jupiter.engine.descriptor.MethodTestDescriptor) TestIdentifier(org.junit.platform.launcher.TestIdentifier) Test(org.junit.jupiter.api.Test)

Aggregations

MethodTestDescriptor (org.junit.jupiter.engine.descriptor.MethodTestDescriptor)2 TestIdentifier (org.junit.platform.launcher.TestIdentifier)2 Test (org.junit.jupiter.api.Test)1 ClassTestDescriptor (org.junit.jupiter.engine.descriptor.ClassTestDescriptor)1 TestFactoryTestDescriptor (org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor)1 TestDescriptor (org.junit.platform.engine.TestDescriptor)1 UniqueId (org.junit.platform.engine.UniqueId)1 AssertionFailedError (org.opentest4j.AssertionFailedError)1 MultipleFailuresError (org.opentest4j.MultipleFailuresError)1