Skip to content
Browse files

Add description of assertEqual check

  • Loading branch information...
1 parent f540c7a commit 713e6d730ed2e0d0dd5f043515a65fea5a50b393 @Alex-Rongzhen-Huang Alex-Rongzhen-Huang committed Mar 9, 2012
View
12 src/test/java/com/ericsson/javatraining/contacts/ContactTest.java
@@ -37,29 +37,29 @@ public void tearDown() throws Exception {
@Test
public void testContactBuildup() {
- assertEquals(testContact.getName(), "TestName");
- assertEquals(testContact.getPhoneNumber(), "123456789011");
- assertEquals(testContact.getAddress(), "Shanghai China");
+ assertEquals("testContactBuildup name fail", testContact.getName(), "TestName");
+ assertEquals("testContactBuildup phoneNumber fail", testContact.getPhoneNumber(), "123456789011");
+ assertEquals("testContactBuildup address fail", testContact.getAddress(), "Shanghai China");
}
@Test
public void testSetName() {
testContact.setName("Modified name");
- assertEquals(testContact.getName(), "Modified name");
+ assertEquals("testSetName fail", testContact.getName(), "Modified name");
}
@Test
public void testSetPhoneNumber() {
testContact.setPhoneNumber("1198838383891");
- assertEquals(testContact.getPhoneNumber(), "1198838383891");
+ assertEquals("testSetPhoneNumber fail", testContact.getPhoneNumber(), "1198838383891");
}
@Test
public void testSetAddress() {
testContact.setAddress("Beijing China");
- assertEquals(testContact.getAddress(), "Beijing China");
+ assertEquals("testSetAddress fail", testContact.getAddress(), "Beijing China");
}
}
View
4 src/test/java/com/ericsson/javatraining/contacts/searchtool/SearchToolTest.java
@@ -54,7 +54,7 @@ public void testSearchRecordsWithNoRecord() throws IOException {
testStorage.loadData();
searchResult = SearchTool.getSearchRecordsString("NoSuchName", testStorage);
- assertEquals(searchResult, "Record not found.");
+ assertEquals("testSearchRecordsWithNoRecord failed", searchResult, "Record not found.");
}
/**
@@ -70,7 +70,7 @@ public void testSearchRecordsWithRecordFound() throws IOException {
testStorage.loadData();
testContactRecord = SearchTool.getSearchRecordsString("Alex", testStorage);
- assertEquals(testContactRecord, "Name\tPhoneNumber\tAddress\nAlex\t123456\tA street room5\n");
+ assertEquals("testSearchRecordsWithRecordFound failed",testContactRecord, "Name\tPhoneNumber\tAddress\nAlex\t123456\tA street room5\n");
}
/**
View
26 src/test/java/com/ericsson/javatraining/contacts/storage/StorageTest.java
@@ -8,7 +8,6 @@
package com.ericsson.javatraining.contacts.storage;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -73,13 +72,13 @@ public void checkDataTest() throws IOException {
testStorage.loadData();
testContactRecord = SearchTool.getSearchRecordsString("Alex", testStorage);
- assertEquals(testContactRecord, "Name\tPhoneNumber\tAddress\nAlex\t123456\tA street room5\n");
+ assertEquals("checkDataTest failed", testContactRecord, "Name\tPhoneNumber\tAddress\nAlex\t123456\tA street room5\n");
}
@Test
public void setDataFileTest() throws IOException {
testStorage.setDataFile("testPath:\testFile");
- assertEquals(testStorage.getDataFile(), "testPath:\testFile");
+ assertEquals("setDataFileTest failed", testStorage.getDataFile(), "testPath:\testFile");
}
@Test
@@ -103,12 +102,9 @@ public void saveDataExceptionTest() throws Exception {
mockStatic(DocumentBuilderFactory.class);
when(DocumentBuilderFactory.newInstance()).thenReturn(mockDocumentBuilderFactory);
when(mockDocumentBuilderFactory.newDocumentBuilder()).thenThrow(testParserConfigurationException);
- try {
- testStorage.loadData();
- testStorage.saveData();
- } catch (Exception e) {
- fail("saveDataExceptionTest exception captured.");
- }
+
+ testStorage.loadData();
+ testStorage.saveData();
}
@Test
@@ -123,11 +119,7 @@ public void loadDataSAXExceptionTest() throws Exception {
when(mockDocumentBuilder.parse(anyString())).thenThrow(testSAXException);
- try {
- testStorage.loadData();
- } catch (Exception e) {
- fail("loadDataExceptionTest exception captured.");
- }
+ testStorage.loadData();
}
@Test
@@ -139,10 +131,6 @@ public void loadDataParserConfigurationExceptionTest() throws Exception {
when(DocumentBuilderFactory.newInstance()).thenReturn(mockDocumentBuilderFactory);
when(mockDocumentBuilderFactory.newDocumentBuilder()).thenThrow(testParserConfigurationException);
- try {
- testStorage.loadData();
- } catch (Exception e) {
- fail("loadDataParserConfigurationExceptionTest exception captured.");
- }
+ testStorage.loadData();
}
}

0 comments on commit 713e6d7

Please sign in to comment.
Something went wrong with that request. Please try again.