Test driven analysis design
Download
1 / 11

- PowerPoint PPT Presentation


  • 168 Views
  • Updated On :

Test-driven Analysis & Design. Jason Gorman. Test-driven Development. Write a unit test that the system currently doesn’t pass Quickly write the code to pass that test Refactor the code to remove any duplication or other design nasties Move on to the next unit test.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about '' - matty


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Test driven analysis design l.jpg

Test-driven Analysis & Design

Jason Gorman

© Jason Gorman 2003


Test driven development l.jpg
Test-driven Development

  • Write a unit test that the system currently doesn’t pass

  • Quickly write the code to pass that test

  • Refactor the code to remove any duplication or other design nasties

  • Move on to the next unit test

© Jason Gorman 2003


Test driven analysis design3 l.jpg
Test-driven Analysis & Design

  • Agree a test scenario at the system level (described purely in terms of inputs and outputs) that the system currently doesn’t pass

  • Quickly do the analysis and high-level design for how the system will pass that test

  • Implement the design using Test-driven Development

  • Customer checks that the test has been passed

  • Move on to the next system test scenario

© Jason Gorman 2003


Agreeing system test scenarios l.jpg

  • Initial Conditions:

  • First Name is not blank

  • Last Name is not blank

  • Email Address is valid

  • Password is not blank

  • Confirm Password = Password

  • Action(s): Click Submit button

  • Outcome:

  • A new user account is created with a status of Awaiting Activation

  • The user account’s First Name = Registration First Name

  • User account’s Last Name = Registration Last Name

  • User account’s Email = Registration Email

  • User account’s Password = Registration Password

  • An email is sent to the User account’s email address, with the subject “<<web site name>> Registration Confirmation”, which contains instructions to activate the user’s account and a link that the user can follow that will set their account’s status to Activated and redirect them to the home page.

Agreeing System Test Scenarios

Registration

Jason

First Name

Gorman

Last Name

[email protected]

Email Address

Password

********

Confirm Password

********

Submit

Click()

Registration Confirmation

Thank you for registering, Jason Gorman. An email has been sent to [email protected] To activate your account please click on the activation link in the email.

© Jason Gorman 2003


Modeling initial conditions l.jpg
Modeling Initial Conditions

: Application

: Session

webmaster

webmaster : User

activeView

: RegistrationView

email = “[email protected]

firstName = “Jason”

lastName = “Gorman”

emailAddress = “[email protected]

password = “password”

confirmPassword = “password”

users

sessions

: SmtpServer

: User

: User

: User

users

name = “Somesite”

© Jason Gorman 2003


Modeling outcomes l.jpg
Modeling Outcomes

: Application

: Session

webmaster

webmaster : User

activeView

: RegistrationView

email = “[email protected]

firstName = “Jason”

lastName = “Gorman”

emailAddress = “[email protected]

password = “password”

confirmPassword = “password”

users

sessions

: RegistrationConfirmationView

Message = “Thank you for registering, Jason Gorman. An email has been sent to [email protected] To activate your account please click on the activation link in the email.”

: SmtpServer

sentItems

activeView

: Email

to = “[email protected]

from = “[email protected]

subject = “Somesite Registration Confirmation”

body = “Please click on the link to activate your account.

http://www.somesite.com/activate.aspx?id=5675”

newUser : User

: User

: User

users

: User

id = 5675

firstName = “Jason”

lastName = “Gorman”

emailAddress = “[email protected]

password = “password”

status = #awaitingActivation

users

name = “Somesite”

© Jason Gorman 2003


Enumerate the outcomes l.jpg

  • confirmation = new RegistrationConfirmationView

  • confirmation.message = “Thank you for registering, “ + registration.firstName + “ “ + registration.lastName” + “. An email has been sent to “ + registration.email + “. To activate your account please click on the activation link in the email.”

  • session.activeView = confirmation

  • newUser = new User

  • newUser.firstName = registration.firstName

  • newUser.lastName = registration.lastName

  • newUser.emailAddress = registration.email

  • newUser.password = registration.password

  • newUser.status = #awaitingActivation

  • newUser.id = User.nextId

  • application.users = [email protected] + newUser

  • mail = new Email

  • mail.to = newUser.emailAddress

  • mail.from = application.webmaster.emailAddress

  • mail.subject = application.name + “ Registration Confirmation”

  • mail.body = “Please click on the link to activate your account.

  • http://www.somesite.com/activate.aspx?id =“ + newUser.id

  • mailSewrver.sentItems = mailServer.sentItems + mail

Enumerate the outcomes

application : Application

session : Session

webmaster

webmaster : User

activeView

registration : RegistrationView

email = “[email protected]

firstName = “Jason”

lastName = “Gorman”

emailAddress = “[email protected]

password = “password”

confirmPassword = “password”

users

sessions

confirmation : RegistrationConfirmationView

Message = “Thank you for registering, Jason Gorman. An email has been sent to [email protected] To activate your account please click on the activation link in the email.”

: SmtpServer

sentItems

activeView

: Email

to = “[email protected]

from = “[email protected]

subject = “Somesite Registration Confirmation”

body = “Please click on the link to activate your account.

http://www.somesite.com/activate.aspx?id=5675”

newUser : User

: User

: User

users

: User

id = 5675

firstName = “Jason”

lastName = “Gorman”

emailAddress = “[email protected]

password = “password”

status = #awaitingActivation

users

name = “Somesite”

© Jason Gorman 2003


Assigning responsibility for outcomes l.jpg
Assigning Responsibility For Outcomes

registration : RegistrationView

: RegistrationController

application : Application

submit.click()

createUser(registration.firstName, registration.lastName, registration.email, registration.password)

User(firstName, lastName, email, password)

newUser : User

  • newUser = new User

addUser(newUser)

  • newUser.firstName = registration.firstName

  • newUser.lastName = registration.lastName

  • newUser.emailAddress = registration.email

  • newUser.password = registration.password

  • newUser.status = #awaitingActivation

  • newUser.id = User.nextId

© Jason Gorman 2003


Interaction models imply a list of unit tests l.jpg
Interaction models imply a list of unit tests

registration : RegistrationView

: RegistrationController

application : Application

submit.click()

createUser(registration.firstName, registration.lastName, registration.email, registration.password)

User(firstName, lastName, email, password)

newUser : User

  • [Test]

  • public void CreateUserTest()

  • {

    • string firstName = “Jason”;

    • string lastname = “Gorman”;

    • string email = “[email protected]”;

    • string password = “password’;

    • int lastId = User.LastId;

  • User newUser = new User(firstName, lastName, email, password);

  • Assertion.AssertEquals(firstName, newUser.FirstName);

  • Assertion.AssertEquals(lastname, newUser.LastName);

  • Assertion.AssertEquals(email, newUser.EmailAddress);

  • Assertion.AssertEquals(password, newUser.Password);

  • Assertion.AssertEquals(newUser.Status = UserStatus.AwaitingActivation;

  • Assertion.AssertEquals(lastId + 1, newUser.Id);

  • }

addUser(newUser)

© Jason Gorman 2003


Next steps l.jpg
Next Steps…

  • Once you have passed the overall system test (which may require some creative problem solving to handle UI testing) go straight to the customer for acceptance testing

  • If you get the green light from the customer, move on to the next system test scenario

© Jason Gorman 2003


Slide11 l.jpg
Tips

  • I often find class diagrams surplus to requirements. The class model is in the code, as far as I’m concerned

  • If you’re asked to produce a class diagram, consider using the code as the basis for this model (removing any unnecessary implementation detail, of course)

  • Don’t forget to integrate your changes every few unit tests

  • Validate that individual user actions, when performed in a sequence, satisfy a use case scenario by acceptance testing of those scenarios. You can also validate them up front to a certain extent by using slideshows that animate the UI from one action to the next. Snapshots put together in a sequence (a “filmstrip”) can also be used to validate in this way – but remember, just because your UI slideshows satisfy the requirements doesn’t mean your code will! You still have to test the real thing. Get that feedback as soon as you can before you consider moving on to the next scenario.

© Jason Gorman 2003


ad