From 423a529f56a9fe3f343b0b92782dc215d1bd9551 Mon Sep 17 00:00:00 2001 From: Justin Albano Date: Thu, 14 Nov 2019 20:50:45 -0500 Subject: [PATCH] BAEL-3444: Simplified example steps --- .../books/BookStoreIntegrationTest.java | 1 - .../books/BookStoreRegistryConfigurer.java | 4 -- .../cucumber/books/BookStoreRunSteps.java | 4 +- .../resources/features/book-store.feature | 52 ++++++++----------- 4 files changed, 25 insertions(+), 36 deletions(-) diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreIntegrationTest.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreIntegrationTest.java index 233fd3c489..5ed2700af8 100644 --- a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreIntegrationTest.java +++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreIntegrationTest.java @@ -5,7 +5,6 @@ import org.junit.runner.RunWith; import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; - @RunWith(Cucumber.class) @CucumberOptions(features = "classpath:features/book-store.feature") public class BookStoreIntegrationTest { diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRegistryConfigurer.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRegistryConfigurer.java index e8e7e91994..d76cfcbfd3 100644 --- a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRegistryConfigurer.java +++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRegistryConfigurer.java @@ -18,7 +18,6 @@ public class BookStoreRegistryConfigurer implements TypeRegistryConfigurer { @Override public void configureTypeRegistry(TypeRegistry typeRegistry) { typeRegistry.defineDataTableType(new DataTableType(BookCatalog.class, new BookTableTransformer())); - } private static class BookTableTransformer implements TableTransformer { @@ -34,11 +33,8 @@ public class BookStoreRegistryConfigurer implements TypeRegistryConfigurer { .map(fields -> new Book(fields.get(0), fields.get(1))) .forEach(catalog::addBook); - System.out.println(catalog); - return catalog; } } - } diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRunSteps.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRunSteps.java index f87bac682f..2af94e5b42 100644 --- a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRunSteps.java +++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRunSteps.java @@ -43,8 +43,8 @@ public class BookStoreRunSteps { } } - @Given("^I have the following books in the store with custom table parsing$") - public void haveBooksInTheStoreByListOfDomainObjects(BookCatalog catalog) { + @Given("^I have the following books in the store with transformer$") + public void haveBooksInTheStoreByListOfTransformer(BookCatalog catalog) { store.addAllBooks(catalog.getBooks()); } diff --git a/testing-modules/testing-libraries/src/test/resources/features/book-store.feature b/testing-modules/testing-libraries/src/test/resources/features/book-store.feature index 6b416508dc..6378477349 100644 --- a/testing-modules/testing-libraries/src/test/resources/features/book-store.feature +++ b/testing-modules/testing-libraries/src/test/resources/features/book-store.feature @@ -1,33 +1,27 @@ Feature: Book Store Scenario: Correct non-zero number of books found by author by list - Given I have the following books in the store by list - | The Devil in the White City | Erik Larson | - | The Lion, the Witch and the Wardrobe | C.S. Lewis | - | In the Garden of Beasts | Erik Larson | - | Jane Eyre | Charlotte Bronte | - | Frankenstein | Mary Shelley | - When I search for books by author Erik Larson - Then I find 2 books - + Given I have the following books in the store by list + | The Devil in the White City | Erik Larson | + | The Lion, the Witch and the Wardrobe | C.S. Lewis | + | In the Garden of Beasts | Erik Larson | + When I search for books by author Erik Larson + Then I find 2 books + Scenario: Correct non-zero number of books found by author by map - Given I have the following books in the store by map - | title | author | - | The Devil in the White City | Erik Larson | - | The Lion, the Witch and the Wardrobe | C.S. Lewis | - | In the Garden of Beasts | Erik Larson | - | Jane Eyre | Charlotte Bronte | - | Frankenstein | Mary Shelley | - When I search for books by author Erik Larson - Then I find 2 books - - Scenario: Correct non-zero number of books found by author with custom table parsing - Given I have the following books in the store with custom table parsing - | title | author | - | The Devil in the White City | Erik Larson | - | The Lion, the Witch and the Wardrobe | C.S. Lewis | - | In the Garden of Beasts | Erik Larson | - | Jane Eyre | Charlotte Bronte | - | Frankenstein | Mary Shelley | - When I search for books by author Erik Larson - Then I find 2 books \ No newline at end of file + Given I have the following books in the store by map + | title | author | + | The Devil in the White City | Erik Larson | + | The Lion, the Witch and the Wardrobe | C.S. Lewis | + | In the Garden of Beasts | Erik Larson | + When I search for books by author Erik Larson + Then I find 2 books + + Scenario: Correct non-zero number of books found by author with transformer + Given I have the following books in the store with transformer + | title | author | + | The Devil in the White City | Erik Larson | + | The Lion, the Witch and the Wardrobe | C.S. Lewis | + | In the Garden of Beasts | Erik Larson | + When I search for books by author Erik Larson + Then I find 2 books \ No newline at end of file