diff --git a/README.md b/README.md index 4b36857..02635d0 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ # Behavior-Driven Development with Cucumber -This is a sample Android app that has tests mostly written using the Cucumber framework. The app acts like a library book search, allowing you to search for books by title, author or year. **The test coverage is 97%**. +This is a sample Android app that has tests mostly written using the Cucumber framework. The app acts like a library book search, allowing you to search for books by title, author or year. -[Cucumber](https://cucumber.io/) is a BDD testing framework that allows people without programming background write specifications **that can be translated to unit tests almost automatically**. - -Writing tests turns more fun and it's no more a pain in the ass to write them first. It's also easier to specify the requirements. +[Cucumber](https://cucumber.io/) is a BDD testing framework that allows people without programming background write specifications **that can be translated to unit test requirements almost automatically**. ## An example -The Oulu City Library has an application for book management. +The Springfield City Library has an application for book management. The application is working fine, but they don't have a search feature. For the first version of the search feature, there's only one thing to implement: @@ -20,14 +18,13 @@ This translates to the following **Gherkin** syntax, which could be even written ```gherkin Feature: Book Search - Scenario: Search books by author - Given there's a book called "Tips for horrible hangovers" written by "John Smith" - And there's a book called "Bananas and their many colors" written by "James Brown" + Given there's a book called "Tips for job interviews" written by "John Smith" + And there's a book called "Bananas and their many colors" written by "James Doe" And there's a book called "Mama look I'm a rock star" written by "John Smith" When an employee searches by author "John Smith" Then 2 books should be found - And Book 1 has the title "Tips for horrible hangovers" + And Book 1 has the title "Tips for job interviews" And Book 2 has the title "Mama look I'm a rock star" ``` diff --git a/app/src/main/java/com/codemate/booklibrary/data/Book.java b/app/src/main/java/com/codemate/booklibrary/data/Book.java index abb40a8..cc90ae8 100644 --- a/app/src/main/java/com/codemate/booklibrary/data/Book.java +++ b/app/src/main/java/com/codemate/booklibrary/data/Book.java @@ -2,9 +2,6 @@ package com.codemate.booklibrary.data; import java.util.Date; -/** - * Created by ironman on 01/09/16. - */ public class Book { private final String title; private final String author; diff --git a/app/src/main/java/com/codemate/booklibrary/data/Library.java b/app/src/main/java/com/codemate/booklibrary/data/Library.java index c9483ae..060ed3b 100644 --- a/app/src/main/java/com/codemate/booklibrary/data/Library.java +++ b/app/src/main/java/com/codemate/booklibrary/data/Library.java @@ -4,9 +4,6 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; -/** - * Created by ironman on 01/09/16. - */ public class Library { private List inventory = new ArrayList<>(); diff --git a/app/src/main/java/com/codemate/booklibrary/data/RandomBookGenerator.java b/app/src/main/java/com/codemate/booklibrary/data/RandomBookGenerator.java index c211120..9f1f3dd 100644 --- a/app/src/main/java/com/codemate/booklibrary/data/RandomBookGenerator.java +++ b/app/src/main/java/com/codemate/booklibrary/data/RandomBookGenerator.java @@ -5,9 +5,6 @@ import java.util.Calendar; import java.util.Date; import java.util.List; -/** - * Created by ironman on 02/09/16. - */ public class RandomBookGenerator { private static final String[] SUBJECTS = { "Chicken", "Pig", "Hippo", "Dinosaur", "Giraffe", "Orangutan", diff --git a/app/src/main/java/com/codemate/booklibrary/data/RandomUtils.java b/app/src/main/java/com/codemate/booklibrary/data/RandomUtils.java index 9424089..594a74b 100644 --- a/app/src/main/java/com/codemate/booklibrary/data/RandomUtils.java +++ b/app/src/main/java/com/codemate/booklibrary/data/RandomUtils.java @@ -2,9 +2,6 @@ package com.codemate.booklibrary.data; import java.util.Random; -/** - * Created by ironman on 02/09/16. - */ public class RandomUtils { private RandomUtils() {} diff --git a/app/src/main/java/com/codemate/booklibrary/ui/BookAdapter.java b/app/src/main/java/com/codemate/booklibrary/ui/BookAdapter.java index 8291f25..4292aed 100644 --- a/app/src/main/java/com/codemate/booklibrary/ui/BookAdapter.java +++ b/app/src/main/java/com/codemate/booklibrary/ui/BookAdapter.java @@ -14,9 +14,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -/** - * Created by ironman on 02/09/16. - */ public class BookAdapter extends RecyclerView.Adapter { private final SimpleDateFormat dateFormat; private List items = new ArrayList<>(); diff --git a/app/src/main/java/com/codemate/booklibrary/ui/MainPresenter.java b/app/src/main/java/com/codemate/booklibrary/ui/MainPresenter.java index e682008..24a73cd 100644 --- a/app/src/main/java/com/codemate/booklibrary/ui/MainPresenter.java +++ b/app/src/main/java/com/codemate/booklibrary/ui/MainPresenter.java @@ -8,9 +8,6 @@ import com.codemate.booklibrary.data.RandomBookGenerator; import java.util.List; -/** - * Created by ironman on 02/09/16. - */ public class MainPresenter { private final MainView mainView; private final Library library; diff --git a/app/src/main/java/com/codemate/booklibrary/ui/MainView.java b/app/src/main/java/com/codemate/booklibrary/ui/MainView.java index 2886e3c..b4e24d8 100644 --- a/app/src/main/java/com/codemate/booklibrary/ui/MainView.java +++ b/app/src/main/java/com/codemate/booklibrary/ui/MainView.java @@ -4,9 +4,6 @@ import com.codemate.booklibrary.data.Book; import java.util.List; -/** - * Created by ironman on 02/09/16. - */ public interface MainView { void showBooks(List books); } diff --git a/app/src/test/java/com/codemate/booklibrary/CucumberTests.java b/app/src/test/java/com/codemate/booklibrary/CucumberTests.java index e65df71..1580eed 100644 --- a/app/src/test/java/com/codemate/booklibrary/CucumberTests.java +++ b/app/src/test/java/com/codemate/booklibrary/CucumberTests.java @@ -7,9 +7,6 @@ import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; -/** - * Created by ironman on 01/09/16. - */ @RunWith(Cucumber.class) @CucumberOptions(features = "src/test/resources") public class CucumberTests extends TestCase { diff --git a/app/src/test/java/com/codemate/booklibrary/data/LibraryTest.java b/app/src/test/java/com/codemate/booklibrary/data/LibraryTest.java index f31c8ee..d04405a 100644 --- a/app/src/test/java/com/codemate/booklibrary/data/LibraryTest.java +++ b/app/src/test/java/com/codemate/booklibrary/data/LibraryTest.java @@ -5,9 +5,6 @@ import org.junit.Test; import java.util.List; -/** - * Created by ironman on 02/09/16. - */ public class LibraryTest { @Test public void addMultipleBooks_PersistsThemInLibrary() { diff --git a/app/src/test/java/com/codemate/booklibrary/data/RandomBookGeneratorTest.java b/app/src/test/java/com/codemate/booklibrary/data/RandomBookGeneratorTest.java index a992422..4c9c378 100644 --- a/app/src/test/java/com/codemate/booklibrary/data/RandomBookGeneratorTest.java +++ b/app/src/test/java/com/codemate/booklibrary/data/RandomBookGeneratorTest.java @@ -8,9 +8,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -/** - * Created by ironman on 02/09/16. - */ public class RandomBookGeneratorTest { @Test public void generatingRandomBooks_ReturnsNonEmptyBookList() { diff --git a/app/src/test/java/com/codemate/booklibrary/steps/BookSearchSteps.java b/app/src/test/java/com/codemate/booklibrary/steps/BookSearchSteps.java index 2f3f8fe..8cc8c5f 100644 --- a/app/src/test/java/com/codemate/booklibrary/steps/BookSearchSteps.java +++ b/app/src/test/java/com/codemate/booklibrary/steps/BookSearchSteps.java @@ -25,9 +25,6 @@ import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -/** - * Created by ironman on 01/09/16. - */ public class BookSearchSteps { private Library library = new Library(); private List results = new ArrayList<>(); @@ -75,7 +72,7 @@ public class BookSearchSteps { @And("^Book (\\d+) should have the title \"([^\"]*)\"$") public void verifyBookAtPosition(int position, String title) throws Throwable { int realPosition = position - 1; - Assert.assertEquals(title, results.get(realPosition).getTitle()); + assertEquals(title, results.get(realPosition).getTitle()); } @And("^Books should be (.+)$") diff --git a/app/src/test/java/com/codemate/booklibrary/ui/MainPresenterTest.java b/app/src/test/java/com/codemate/booklibrary/ui/MainPresenterTest.java index 9643c9b..151865e 100644 --- a/app/src/test/java/com/codemate/booklibrary/ui/MainPresenterTest.java +++ b/app/src/test/java/com/codemate/booklibrary/ui/MainPresenterTest.java @@ -18,9 +18,6 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -/** - * Created by ironman on 02/09/16. - */ public class MainPresenterTest { private static final List DUMMY_BOOKS = Arrays.asList( new Book("Sample book one", "John Doe", Date.valueOf("2000-10-25")),