use of org.junit.jupiter.api.DynamicTest in project tutorials by eugenp.
the class DynamicTests method dynamicUserTestCollection.
@TestFactory
public Stream<DynamicTest> dynamicUserTestCollection() {
List<User> inputList = Arrays.asList(new User("john@yahoo.com", "John"), new User("ana@yahoo.com", "Ana"));
Function<User, String> displayNameGenerator = (input) -> "Saving user: " + input;
UserDAO userDAO = new UserDAO();
ThrowingConsumer<User> testExecutor = (input) -> {
userDAO.add(input);
assertNotNull(userDAO.findOne(input.getEmail()));
};
return DynamicTest.stream(inputList.iterator(), displayNameGenerator, testExecutor);
}
use of org.junit.jupiter.api.DynamicTest in project acceptance-testing by Abhigulve.
the class EventHandler method TestInitiator.
@TestFactory
public Collection<DynamicTest> TestInitiator() {
domManipulation.open(jr.getManupulatorBean().getUrl());
String testName = jr.getManupulatorBean().getTestName();
List<List<Map<String, String>>> list = jr.getManupulatorBean().getList();
Collection<DynamicTest> dynamicTests = new ArrayList<>();
for (int j = 0; j < list.size(); j++) {
domManipulation.open(jr.getManupulatorBean().getUrl());
List<Map<String, String>> testCase = list.get(j);
int i = 0;
for (int values = 1; values < testCase.size(); values++) {
Map<String, String> map = testCase.get(values);
domManipulation.action(map.get("id").toString(), map.get("value"), map.get("event").toUpperCase());
i++;
if (i == (testCase.size())) {
DynamicTest dTest = DynamicTest.dynamicTest(testName, () -> domManipulation.testCaseAnalyser(map.get("id").toString(), map.get("condition").toUpperCase()));
dynamicTests.add(dTest);
}
}
}
return dynamicTests;
}
use of org.junit.jupiter.api.DynamicTest in project flue2ent by DefinityLabs.
the class ScenarioTest method test_returnsDynamicTest.
@Test
public void test_returnsDynamicTest() throws Throwable {
Scenario scenario = Scenario.title("Title").given(stepOne).build();
DynamicTest test = scenario.test(website);
assertThat(test.getDisplayName()).isEqualTo(scenario.getTitle());
test.getExecutable().execute();
verify(stepOne).execute();
}
use of org.junit.jupiter.api.DynamicTest in project robozonky by RoboZonky.
the class JmxListenerServiceTest method getParametersForInvestmentMade.
private DynamicTest getParametersForInvestmentMade() {
final Loan l = mockLoan();
final Investment i = Investment.fresh((MarketplaceLoan) l, 200);
final PortfolioOverview po = PortfolioOverview.calculate(BigDecimal.valueOf(1000), Stream::empty);
final Event evt = new InvestmentMadeEvent(i, l, po);
final Consumer<SoftAssertions> before = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getSuccessfulInvestments()).isEmpty();
};
final Consumer<SoftAssertions> after = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getSuccessfulInvestments()).containsOnlyKeys(l.getId());
softly.assertThat(mbean.getLatestUpdatedDateTime()).isEqualTo(evt.getCreatedOn());
};
return getParameters(evt, before, after);
}
use of org.junit.jupiter.api.DynamicTest in project robozonky by RoboZonky.
the class JmxListenerServiceTest method getParametersForInvestmentPurchased.
private DynamicTest getParametersForInvestmentPurchased() {
final Loan l = mockLoan();
final Investment i = Investment.fresh((MarketplaceLoan) l, 200);
final Event evt = new InvestmentPurchasedEvent(i, l, PortfolioOverview.calculate(BigDecimal.valueOf(2000), Stream::empty));
final Consumer<SoftAssertions> before = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getPurchasedInvestments()).isEmpty();
};
final Consumer<SoftAssertions> after = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getPurchasedInvestments()).containsOnlyKeys(i.getLoanId());
softly.assertThat(mbean.getLatestUpdatedDateTime()).isEqualTo(evt.getCreatedOn());
};
return getParameters(evt, before, after);
}
Aggregations