Exercise 16 ( Chapter 22 )


Exercise 16 (Chapter 22)

Q1:

Assume you've written the following test for creating tasks in the XTrack system:

 public class TaskStoryTest {     public void testCreate() {       login("bob","bobspassword");       assertTrue( addTask( "User Gui",                            "Create GUI",                            "Bob",                            "2",                            "3",                            "Not Started" ) );    } } 

Indicate the modifications required to TaskStoryTest to make it run.

A1:

TaskStoryTest.java

 public class TaskStoryTest extends XTrackTest {     public TaskStoryTest(String name) {super(name); }    public void testCreate() {        login("bob","bobspassword");       assertTrue( addTask( "User Gui",                            "Create GUI",                            "Bob",                            "2",                            "3",                            "Not Started" ) );    } } 
Q2:

Assume you've already gotten LoginStoryTest and UserIdStoryTest to run as illustrated in this chapter. Assume that the code in the XTrack system that creates tasks works as follows:

An XTrackTask class in the XTrack system represents a task. An XTrackTask has an add method that sets the task's name, description, assignee, estimate, actual, and status fields to values specified as parameters. If the specified values are all valid, it then attempts to add the task to the database. If the addition is successful, it returns true; otherwise, if the add fails or if any of the specified values is invalid, it returns false.

Show what you'd have to add to XTrackTest to call this code and make the TaskStoryTest run.

A1:

XTrackTest.java

 import junit.framework.*;  import xtrack.*; public class XTrackTest extends TestCase {    public XTrackTest(String name) {super(name); }    public void assertFalse( boolean b) {          assertTrue(!b);    }    public boolean login( String id,String psw) {         XTrackSession session = new XTrackSession();         return session.login(id,psw);    }    public boolean createUserId( String id, String psw,                                 String email) {          XTrackUser user = new XTrackUser();          return user.create(id,psw,email);    }    public boolean deleteUserId( String id) {             XTrackUser user = new XTrackUser(id);           return user.delete();    }    public boolean createTask( String name,                               String description,                               String assignee,                               String estimate,                               String actual,                               String state) {      XTrackTask task = new XTrackTask();     return task.add(name,                          description,                          assignee,                          estimate,                          actual,                          state);    } } 



Testing Extreme Programming
Testing Extreme Programming
ISBN: 0321113551
EAN: 2147483647
Year: 2005
Pages: 238

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net