Search in sources :

Example 1 with InvokedMethodNameListener

use of io.github.sskorol.listeners.InvokedMethodNameListener in project selenium_java by sergueik.

the class BaseTest method run.

static InvokedMethodNameListener run(final Class<?>... testClasses) {
    final TestNG tng = create(testClasses);
    final InvokedMethodNameListener listener = new InvokedMethodNameListener();
    final DataProviderTransformer dataProviderTransformer = new DataProviderTransformer();
    tng.addListener((ITestNGListener) listener);
    tng.addListener(dataProviderTransformer);
    tng.setDefaultTestName("DataSupplier tests");
    tng.run();
    return listener;
}
Also used : InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) DataProviderTransformer(io.github.sskorol.dataprovider.DataProviderTransformer) TestNG(org.testng.TestNG)

Example 2 with InvokedMethodNameListener

use of io.github.sskorol.listeners.InvokedMethodNameListener in project selenium_java by sergueik.

the class DataSupplierTests method dataSuppliersWithInjectedArgsShouldWork.

@Test
public void dataSuppliersWithInjectedArgsShouldWork() {
    final InvokedMethodNameListener listener = run(InjectedArgsDataSupplierTests.class);
    assertThat(listener.getSucceedMethodNames()).hasSize(4).containsExactly("supplyContextMetaData(DataSupplier tests)", "supplyFullMetaData(DataSupplier tests,supplyFullMetaData)", "supplyMethodMetaData(supplyMethodMetaData)", "supplyWrongArgTypeMethodMetaData(data)");
    assertThat(listener.getSkippedBeforeInvocationMethodNames()).hasSize(1).containsExactly("supplyNullArgTypeMethodMetaData()");
    assertThat(EntryStream.of(listener.getResults()).values().toList()).filteredOn(r -> r.getStatus() == ITestResult.SKIP).extracting(ITestResult::getThrowable).extracting(Throwable::getMessage).containsExactly("java.lang.IllegalArgumentException: Nothing to return from data supplier. The following test will be skipped: InjectedArgsDataSupplierTests.supplyNullArgTypeMethodMetaData.");
}
Also used : InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) Collection(java.util.Collection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.testng.annotations.Test) EntryStream(one.util.streamex.EntryStream) ITestResult(org.testng.ITestResult) InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) ITestResult(org.testng.ITestResult) Test(org.testng.annotations.Test)

Example 3 with InvokedMethodNameListener

use of io.github.sskorol.listeners.InvokedMethodNameListener in project selenium_java by sergueik.

the class DataSupplierTests method tupleDataSupplierTestsShouldWork.

@Test
public void tupleDataSupplierTestsShouldWork() {
    final InvokedMethodNameListener listener = run(TupleDataSupplierTests.class);
    assertThat(listener.getSucceedMethodNames()).hasSize(4).containsExactly("supplyCommonTupleData(data1)", "supplyCommonTupleData(data2)", "supplyExternalTupleData(1,2,3.0)", "supplyExtractedTupleData(1,User(name=name, password=password))");
}
Also used : InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) Test(org.testng.annotations.Test)

Example 4 with InvokedMethodNameListener

use of io.github.sskorol.listeners.InvokedMethodNameListener in project selenium_java by sergueik.

the class DataSupplierTests method missingDataSuppliersShouldNotWork.

@Test
public void missingDataSuppliersShouldNotWork() {
    final InvokedMethodNameListener listener = run(MissingDataSupplierTests.class);
    assertThat(listener.getFailedBeforeInvocationMethodNames()).hasSize(2).containsExactly("failOnDataSupplying()", "failOnExternalDataSupplying()");
    assertThat(EntryStream.of(listener.getResults()).values().toList()).extracting(ITestResult::getThrowable).extracting(t -> t.getMessage().trim()).containsExactly("Method public void io.github.sskorol.testcases.MissingDataSupplierTests.failOnDataSupplying() requires a @DataProvider named : missingDataSupplier", "Method public void io.github.sskorol.testcases.MissingDataSupplierTests.failOnExternalDataSupplying() requires a @DataProvider named : missingExternalDataSupplier in class io.github.sskorol.datasuppliers.ExternalDataSuppliers");
}
Also used : InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) Collection(java.util.Collection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.testng.annotations.Test) EntryStream(one.util.streamex.EntryStream) ITestResult(org.testng.ITestResult) InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) ITestResult(org.testng.ITestResult) Test(org.testng.annotations.Test)

Example 5 with InvokedMethodNameListener

use of io.github.sskorol.listeners.InvokedMethodNameListener in project selenium_java by sergueik.

the class DataSupplierTests method singleObjectDataSuppliersShouldWork.

@Test
public void singleObjectDataSuppliersShouldWork() {
    final InvokedMethodNameListener listener = run(SingleObjectsDataSupplierTests.class);
    assertThat(listener.getSucceedMethodNames()).hasSize(4).containsExactly("supplyCommonObject(data1)", "supplyCustomObjectData(User(name=username, password=password))", "supplyExternalObjectData(0.1)", "supplyPrimitiveData(5)");
}
Also used : InvokedMethodNameListener(io.github.sskorol.listeners.InvokedMethodNameListener) Test(org.testng.annotations.Test)

Aggregations

InvokedMethodNameListener (io.github.sskorol.listeners.InvokedMethodNameListener)12 Test (org.testng.annotations.Test)11 Collection (java.util.Collection)3 ITestResult (org.testng.ITestResult)3 EntryStream (one.util.streamex.EntryStream)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 DataProviderTransformer (io.github.sskorol.dataprovider.DataProviderTransformer)1 TestNG (org.testng.TestNG)1