java - How do I structure an end-to-end test for a delegate model design? -
i ran across delegate-model design (as opposed mvc) , want try out, , have been learning tdd development in goos style lately. i'm wanting walking skeleton test this: (i'm using junit)
@test public void usergeneratesevent_dnotifiesm_mnotifiesdofupdateddata_dgetsnewdatafromm() { model model = new model(); delegate delegate = new delegate(model); model.addlistener(delegate); // not sure how "generate user event" here assert( ... ); } my issue, in comment above, i'm not sure how generate user event within delegate. maybe understanding of how design pattern works off, delegate should encapsulate both view , controller - i'd have have view fire event contoller within delegate, interaction should "secret"?
any input or advice appreciated.
your walking skeleton test should close end-to-end possible. test should gui way web service or database layer if can. validates can connect , can automate deployment , run in production.
however, tests actual web services, , databases may slow or fragile automate. in case test beneath layers using dependency injection.
for testing guis can use gui testing framework test through gui (this did in goos). if using swing, recommend fest. approach more reliable , allows fast acceptance tests test beneath gui layer. this, should use mvp or mvvm instead of delegate-model
i'm still stuck on how go programmatically raising user event. example, user adds row table via ui, , assert @ end number of rows in model equals 1. have break encapsulation of delegate this?
you either have to: break encapulation, use pattern such mvp/mvvm make let test beneath view, or test via gui using fest. recommend using fest raise events having automatically click on components , verify jtable has given number of rows. fest tests reliable, albeit slow shouldn't write unit tests it.
if application grows decent-size (> 3000 loc) can consider refactoring mvp/mvvm because enough benefit code reuse , faster/reliable end-to-end tests justify complexity. fest tests , unit tests (on model) should not break during refactoring , safely refactor. when presenter/view-model separate class can call user events on them directly , verify(with mocks)/assert additional table row added.
Comments
Post a Comment