serenity-bdd / the-serenity-book

A book about Serenity BDD
40 stars 58 forks source link

inconsistent Task examples #30

Closed SiKing closed 4 years ago

SiKing commented 4 years ago

Most of the example code for writing a Task return something like:

return Instrumented.instanceOf(StartWithATodoListContaining.class).withProperties(Lists.newArrayList(todos));

citation

The example code that is created with the command mvn archetype:generate -Dfilter=screenplay has:

return Tasks.instrumented(Search.class, searchTerm);

Both forms seem to work, at least in version 2.2.2 of serenity-core. Is one preferred over the other?

globalworming commented 4 years ago

hmm.. I always use instrumented() because that's the only one I knew about. I may have found it here http://serenity-bdd.info/docs/articles/screenplay-tutorial.html These methods seem to do pretty much the same thing? return stepFactory.getUniqueStepLibraryFor(instanceClass, constructorParameters) The difference is StepFactory.getFactory() in Instrumented StepFactory.getFactory().usingPages(pages) in Tasks Tasks seems specific the screenplay pattern, so I guess it's the preferred one? @wakaleo

SiKing commented 4 years ago

The tutorial you linked is what I was starting from. That is where I found both forms.

wakaleo commented 4 years ago

The code has evolved, but you can use either form - one is a shortcut for the other.

SiKing commented 4 years ago

I guess I will go with what @globalworming said: "Tasks seems specific the screenplay pattern"