Skip to content

Commit

Permalink
[49] Setup CI and ensure tests are passing
Browse files Browse the repository at this point in the history
  • Loading branch information
m133225 authored Sep 16, 2016
1 parent 95055c8 commit 7127241
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 61 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: java
matrix:
include:
- jdk: oraclejdk8
script: travis_retry ./gradlew clean headless allTests coverage coveralls -i
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"

addons:
apt:
packages:
- oracle-java8-installer
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Address Book sample application (Level 4)

- [Gradle](docs/devops/gradle/Introduction to Gradle.md)
- [Configuration](docs/addressbook/Configuration.md)
- [Logging](docs/addressbook/Logging.md)
- [Logging](docs/addressbook/Logging.md)
- [Setting up Travis CI](docs/devops/integration/Configuring Travis CI.md)
13 changes: 11 additions & 2 deletions docs/devops/integration/Configuring Travis CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ If you would like to customise your travis build, do read the [Travis CI Documen
![Signing into Travis CI](../../images/signing_in.png)

3. Head to the [Accounts](https://travis-ci.org/profile) page, and find the switch for the forked repository.
- If the organization is not shown, click `Review and add` as shown
![Review and add](../../images/review_and_add.png)
This should bring you to a GitHub page that manages the access of third-party applications.
Depending on whether you are the owner of the repository, you can either grant access
![Grant Access](../../images/grant_access.png)
or request access
![Request Access](../../images/request_access.png)
to Travis CI so that it can access your commits and build your code.

- If repository cannot be found, click `Sync account`
4. Activate the switch.
![Activate the switch](../../images/flick_repository_switch.png)
Expand All @@ -38,10 +47,10 @@ If you would like to customise your travis build, do read the [Travis CI Documen
- oracle-java8-installer
```
6. To see the CI in action, push a commit to the master branch!
Go to the repository and see the pushed commit. There should be an icon which will link you to the Travis build.
* Go to the repository and see the pushed commit. There should be an icon which will link you to the Travis build.
![Commit build](../../images/build_pending.png)
As the build is run on a provided remote machine, we can only examine the logs it produces:
* As the build is run on a provided remote machine, we can only examine the logs it produces:
![Travis build](../../images/travis_build.png)
7. If the build is successful, you should be able to check the coverage details of the tests at [Coveralls](http://coveralls.io/)!
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/controller/ResultDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* A controller for the status bar that is displayed at the header of the application.
*/
public class ResultDisplay extends BaseUiPart {
public static final String HEADER_STATUS_BAR_ID = "resultDisplay";
public static final String RESULT_DISPLAY_ID = "resultDisplay";
private static final String STATUS_BAR_STYLE_SHEET = "result-display";
private TextArea resultDisplayArea;

Expand All @@ -29,7 +29,7 @@ public static ResultDisplay load(Stage primaryStage, AnchorPane placeHolder) {
public void configure() {
resultDisplayArea = new TextArea();
resultDisplayArea.setEditable(false);
resultDisplayArea.setId(HEADER_STATUS_BAR_ID);
resultDisplayArea.setId(RESULT_DISPLAY_ID);
resultDisplayArea.getStyleClass().removeAll();
resultDisplayArea.getStyleClass().add(STATUS_BAR_STYLE_SHEET);
resultDisplayArea.setText("");
Expand Down
18 changes: 5 additions & 13 deletions src/test/java/guitests/GuiTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ public class GuiTestBase {

protected TypicalTestPersons td = new TypicalTestPersons();

/* Handles to GUI elements present at the start up are created in advance
/*
* Handles to GUI elements present at the start up are created in advance
* for easy access from child classes.
*/
protected MainGuiHandle mainGui;
protected MainMenuHandle mainMenu;
protected PersonListPanelHandle personListPanel;
protected HeaderStatusBarHandle headerStatusBar;
protected ResultDisplayHandle resultDisplay;
private Stage stage;

@BeforeClass
Expand All @@ -61,13 +62,13 @@ public void setup() throws Exception {
mainGui = new MainGuiHandle(new GuiRobot(), stage);
mainMenu = mainGui.getMainMenu();
personListPanel = mainGui.getPersonListPanel();
headerStatusBar = mainGui.getHeaderStatusBar();
resultDisplay = mainGui.getResultDisplay();
this.stage = stage;
});
EventManager.clearSubscribers();
testApp = (TestApp) FxToolkit.setupApplication(() -> new TestApp(this::getInitialData, getDataFileLocation()));
FxToolkit.showStage();
while(!stage.isShowing());
while (!stage.isShowing());
mainGui.focusOnMainApp();
}

Expand Down Expand Up @@ -104,15 +105,6 @@ public void sleep(long duration, TimeUnit timeunit) {
mainGui.sleep(duration, timeunit);
}

public void sleepForGracePeriod() {
mainGui.sleepForGracePeriod();
}

public void sleepUntilNextSync() {
//TODO: actively check for sync status rather than sleep for a fixed time
//sleep(getTestingConfig().getUpdateInterval(), TimeUnit.MILLISECONDS);
}

public void assertMatching(ReadOnlyPerson person, PersonCardHandle card) {
assertTrue(TestUtil.compareCardAndPerson(card, person));
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/guitests/PersonAddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void addPerson_singlePerson_successful() throws IllegalValueException {
public void addPerson_duplicatePerson_showFeedback() throws IllegalValueException {
personListPanel.enterCommandAndApply(td.hoon.getCommandString());
personListPanel.enterCommandAndApply(td.hoon.getCommandString());
assertEquals(AddPersonCommand.MESSAGE_DUPLICATE_PERSON, headerStatusBar.getText());
assertEquals(AddPersonCommand.MESSAGE_DUPLICATE_PERSON, resultDisplay.getText());
}

@Test
Expand All @@ -39,6 +39,6 @@ public void addPerson_multiplePerson_success() throws IllegalValueException {
public void addPerson_invalidCommand_fail() {
personListPanel.enterCommandAndApply("adds Johnny");

assertEquals("Invalid command", headerStatusBar.getText());
assertEquals("Invalid command", resultDisplay.getText());
}
}
6 changes: 3 additions & 3 deletions src/test/java/guitests/PersonDeleteCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ public void deletePerson_middlePerson_successful() throws IllegalValueException
@Test
public void deletePerson_outOfBoundIndex_fail() {
personListPanel.enterCommandAndApply("delete " + (personListPanel.getNumberOfPeople() + 1));
assertEquals("The person index provided is invalid", headerStatusBar.getText());
assertEquals("The person index provided is invalid", resultDisplay.getText());
}

@Test
public void deletePerson_zeroIndex_fail() {
personListPanel.enterCommandAndApply("delete 0");
assertEquals("The person index provided is invalid", headerStatusBar.getText());
assertEquals("The person index provided is invalid", resultDisplay.getText());
}

@Test
public void deletePerson_negativeIndex_fail() {
personListPanel.enterCommandAndApply("delete -1");
assertEquals("The person index provided is invalid", headerStatusBar.getText());
assertEquals("The person index provided is invalid", resultDisplay.getText());
}
}
18 changes: 7 additions & 11 deletions src/test/java/guitests/PersonSearchCommandTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package guitests;

import guitests.guihandles.PersonCardHandle;
import org.junit.Test;
import seedu.address.commands.AddPersonCommand;
import seedu.address.exceptions.IllegalValueException;

import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

Expand All @@ -16,22 +12,22 @@ public class PersonSearchCommandTest extends GuiTestBase {
public void searchPerson_searchInvalidPerson_noResult() throws IllegalValueException {
personListPanel.enterCommandAndApply("find Mark");
assertEquals(0, personListPanel.getNumberOfPeople());
assertEquals("0 persons listed!", headerStatusBar.getText());
assertEquals("0 persons listed!", resultDisplay.getText());
}

@Test
public void searchPerson_withSameLastName_foundMultiple() throws IllegalValueException {
personListPanel.enterCommandAndApply("find Meier");
assertEquals(2, personListPanel.getNumberOfPeople());
assertEquals("2 persons listed!", headerStatusBar.getText());
assertEquals("2 persons listed!", resultDisplay.getText());
assertTrue(personListPanel.isListMatching(td.benson, td.daniel));
}

@Test
public void searchPerson_withUniqueLastName_foundSingle() throws IllegalValueException {
personListPanel.enterCommandAndApply("find Pauline");
assertEquals(1, personListPanel.getNumberOfPeople());
assertEquals("1 persons listed!", headerStatusBar.getText());
assertEquals("1 persons listed!", resultDisplay.getText());
assertTrue(personListPanel.isListMatching(td.alice));
}

Expand All @@ -40,15 +36,15 @@ public void searchPerson_withUniqueLastName_foundSingle() throws IllegalValueExc
public void searchPerson_withUniqueFirstName_foundSingle() throws IllegalValueException {
personListPanel.enterCommandAndApply("find George");
assertEquals(1, personListPanel.getNumberOfPeople());
assertEquals("1 persons listed!", headerStatusBar.getText());
assertEquals("1 persons listed!", resultDisplay.getText());
assertTrue(personListPanel.isListMatching(td.george));
}

@Test
public void searchPerson_withFullName_foundSingle() throws IllegalValueException {
personListPanel.enterCommandAndApply("find Elle Meyer");
assertEquals(1, personListPanel.getNumberOfPeople());
assertEquals("1 persons listed!", headerStatusBar.getText());
assertEquals("1 persons listed!", resultDisplay.getText());
assertTrue(personListPanel.isListMatching(td.elle));
}

Expand All @@ -58,14 +54,14 @@ public void searchPerson_withSameSubsetOfCharacters_foundMultiple() throws Illeg
personListPanel.enterCommandAndApply("find on");
sleep(1, TimeUnit.SECONDS);
assertEquals(2, personListPanel.getNumberOfPeople());
assertEquals("2 persons listed!", headerStatusBar.getText());
assertEquals("2 persons listed!", resultDisplay.getText());
assertTrue(personListPanel.isListMatching(td.benson, td.fiona));
*/
}

@Test
public void searchPerson_invalidCommand_fail() {
personListPanel.enterCommandAndApply("findgeorge");
assertEquals("Invalid command", headerStatusBar.getText());
assertEquals("Invalid command", resultDisplay.getText());
}
}
25 changes: 0 additions & 25 deletions src/test/java/guitests/guihandles/HeaderStatusBarHandle.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/test/java/guitests/guihandles/MainGuiHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public PersonListPanelHandle getPersonListPanel() {
return new PersonListPanelHandle(guiRobot, primaryStage);
}

public HeaderStatusBarHandle getHeaderStatusBar() {
return new HeaderStatusBarHandle(guiRobot, primaryStage);
public ResultDisplayHandle getResultDisplay() {
return new ResultDisplayHandle(guiRobot, primaryStage);
}

public MainMenuHandle getMainMenu() {
Expand Down
25 changes: 25 additions & 0 deletions src/test/java/guitests/guihandles/ResultDisplayHandle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package guitests.guihandles;

import guitests.GuiRobot;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;
import seedu.address.TestApp;
import seedu.address.controller.ResultDisplay;

/**
* A handler for the ResultDisplay of the UI
*/
public class ResultDisplayHandle extends GuiHandle {

public ResultDisplayHandle(GuiRobot guiRobot, Stage primaryStage) {
super(guiRobot, primaryStage, TestApp.APP_TITLE);
}

public String getText() {
return getResultDisplay().getText();
}

private TextArea getResultDisplay() {
return (TextArea) getNode("#" + ResultDisplay.RESULT_DISPLAY_ID);
}
}

0 comments on commit 7127241

Please sign in to comment.