Search in sources :

Example 21 with Executable

use of org.junit.jupiter.api.function.Executable in project cucumber-jvm by cucumber.

the class CucumberTest method testThatParsingErrorsIsNicelyReported.

@Test
void testThatParsingErrorsIsNicelyReported() {
    Executable testMethod = () -> new Cucumber(LexerErrorFeature.class);
    FeatureParserException actualThrown = assertThrows(FeatureParserException.class, testMethod);
    assertThat(actualThrown.getMessage(), equalTo("" + "Failed to parse resource at: classpath:io/cucumber/error/lexer_error.feature\n" + "(1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Feature  FA'\n" + "(3:3): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Scenario SA'\n" + "(4:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Given GA'\n" + "(5:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'When GA'\n" + "(6:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Then TA'"));
}
Also used : FeatureParserException(io.cucumber.core.gherkin.FeatureParserException) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 22 with Executable

use of org.junit.jupiter.api.function.Executable in project cucumber-jvm by cucumber.

the class InjectorSourceFactoryTest method failsToInstantiateClassWithNoDefaultConstructor.

@Test
void failsToInstantiateClassWithNoDefaultConstructor() {
    InjectorSourceFactory injectorSourceFactory = new InjectorSourceFactory(NoDefaultConstructor.class);
    Executable testMethod = injectorSourceFactory::create;
    InjectorSourceInstantiationFailed actualThrown = assertThrows(InjectorSourceInstantiationFailed.class, testMethod);
    assertAll(() -> assertThat("Unexpected exception message", actualThrown.getMessage(), is(equalTo("Instantiation of 'io.cucumber.guice.InjectorSourceFactoryTest$NoDefaultConstructor' failed. Check the caused by exception and ensure yourInjectorSource implementation is accessible and has a public zero args constructor."))), () -> assertThat("Unexpected exception cause class", actualThrown.getCause(), isA(NoSuchMethodException.class)));
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 23 with Executable

use of org.junit.jupiter.api.function.Executable in project cucumber-jvm by cucumber.

the class InjectorSourceFactoryTest method failsToInstantiateClassNotImplementingInjectorSource.

@Test
void failsToInstantiateClassNotImplementingInjectorSource() {
    InjectorSourceFactory injectorSourceFactory = new InjectorSourceFactory(String.class);
    Executable testMethod = injectorSourceFactory::create;
    InjectorSourceInstantiationFailed actualThrown = assertThrows(InjectorSourceInstantiationFailed.class, testMethod);
    assertAll(() -> assertThat("Unexpected exception message", actualThrown.getMessage(), is(equalTo("Instantiation of 'java.lang.String' failed. Check the caused by exception and ensure yourInjectorSource implementation is accessible and has a public zero args constructor."))), () -> assertThat("Unexpected exception cause class", actualThrown.getCause(), isA(ClassCastException.class)));
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 24 with Executable

use of org.junit.jupiter.api.function.Executable in project cucumber-jvm by cucumber.

the class CollectionUtilTest method testIllegalArgumentExceptionIsThrownWhenListIsEmpty.

@Test
void testIllegalArgumentExceptionIsThrownWhenListIsEmpty() {
    Executable testMethod = () -> CollectionUtil.removeAllExceptFirstElement(list);
    IllegalArgumentException expectedThrown = assertThrows(IllegalArgumentException.class, testMethod);
    assertThat(expectedThrown.getMessage(), is(equalTo("List must contain at least one element.")));
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 25 with Executable

use of org.junit.jupiter.api.function.Executable in project neo4j by neo4j.

the class TokenIndexAccessorTest method readerShouldFindRandomizedUpdates.

@Test
void readerShouldFindRandomizedUpdates() throws Throwable {
    Executable additionalOperation = () -> {
    };
    readerShouldFindRandomizedUpdates(additionalOperation);
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Executable (org.junit.jupiter.api.function.Executable)476 Test (org.junit.jupiter.api.Test)434 lombok.val (lombok.val)112 ByteBuf (io.netty.buffer.ByteBuf)83 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)42 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)36 CucumberException (io.cucumber.core.exception.CucumberException)20 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)19 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)15 Feature (io.cucumber.core.gherkin.Feature)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 StepDefinition (io.cucumber.core.backend.StepDefinition)14 Step (io.cucumber.core.gherkin.Step)14 Argument (io.cucumber.core.stepexpression.Argument)14 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)13 LocalChannel (io.netty.channel.local.LocalChannel)12 CucumberBackendException (io.cucumber.core.backend.CucumberBackendException)11 StepExpression (io.cucumber.core.stepexpression.StepExpression)11 SSLEngine (javax.net.ssl.SSLEngine)11 Bootstrap (io.netty.bootstrap.Bootstrap)10