Skip to content

Instantly share code, notes, and snippets.

@varokas
Created March 13, 2012 01:16
Show Gist options
  • Save varokas/2025991 to your computer and use it in GitHub Desktop.
Save varokas/2025991 to your computer and use it in GitHub Desktop.
DAO-Business
interface StudentDAO {
public Iterable<Student> getStudentsByClass(String cls);
}
class StudentDAOTest {
//mock: Database (or use in-memory database)
//test that SQL works and queries the right thing
@Test public void testGetStudentByClassReturnsAllStudentsInClass() {}
@Test public void testGetStudentByClassThrowsExceptionWhenClassIsNull() {}
}
class StudentBusiness {
private StudentDao studentDao;
public Iterable<String> getGrades(String cls) {
students = studentDao.getStudentsByClass(cls);
//process grades and returns
}
}
class StudentBusinessTest {
//mock: StudentDao (supposed that StudentDao returns correct answer)
//test that the grading method works
@Test public void testGetGradesAssignsAToStudentWithScoreOf80OrMore();
@Test public void testGetGradesAssignsBToStudentWithScoreOf60OrMore();
...
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment