QAF 3.0.0-RC1 released with RuntimeScenarioFactory

66 views
Skip to first unread message

cjayswal

unread,
Mar 16, 2020, 11:50:39 PM3/16/20
to qaf-...@googlegroups.com
QAF always tried to make BDD implementation simpler. With Runtime Scenario Factory, now test developer don't need to relay on BDD or feature file and still follow Behavior Driven Development. It will help in making BDD simpler and still will have all feature of QAF BDD like
  • dry-run
  • reporting of each step including not-run steps
  • step listeners
RuntimeScenarioFactory can be useful, where scenario is create during execution in Java code just like reading from BDD or Feature file. It will look like:


 import static com.qmetry.qaf.automation.step.client.RuntimeScenarioFactory.scenario;
 

 @MetaData("{'TestCaseID':'TC-12345'}")
 @Test(description="a sample scenario", ...)
 
public void testWithGivenWhenThen() {

        scenario
().
        given
("a precondition",()->{
               
//write appropriate code...
       
}).
       
when("some action performed",()->{
               
//write appropriate code...
       
}).
       
then("it should have expected outcome",()->{
               
//write appropriate code...
       
}).
        execute
();
 
}

Find details like Random data and expression support in property and more in QAF 3.0.0.

Arisa Ando

unread,
Mar 31, 2020, 8:20:36 AM3/31/20
to qaf users
What about step reuse?

cjayswal

unread,
Apr 1, 2020, 2:53:14 PM4/1/20
to qaf-...@googlegroups.com
Nothing can stop you for calling reusable code inside! Goal is to reduce overhead because of feature file. You should have reusable methods that you can call inside runtime step!

To understand and compare it better, compare it with feature file.

Feature : sample feature

Scenario: scenario-1
Given my stpe-1 # this step can be reusable and let say respective method is step1
When my step-2  # this step can be reusable and and let say respective method is step2
Then expected something for scenario1 # this must be scenario specific and can't be reusable still you have some java method to call by feature file

Scenario: scenario-2
Given my stpe-1 # this step can be reusable and let say respective method is step1
When my step-2  # this step can be reusable and and let say respective method is step2
And my step-3
Then expected something for scenario2 # this must be scenario specific and can't be reusable even if test/scenario specific, you must have one step/method to support BDD using feature/text file

If we remove feature file it may look like below

import static com.qmetry.qaf.automation.step.client.RuntimeScenarioFactory.scenario;
 

 @MetaData("{'feature':'sample feature'}")
 public class myFeature() {

 @MetaData("{'TestCaseID':'TC-12345'}")
 @Test(description="a sample scenario", ...)

 
public void scenario1() {

        scenario
().
        given
("my stpe-1",()-> step1()).
       
when("my step-2",()-> step2()).
       
then("expected something for scenario1",()->{
               
//write appropriate code or call method(s)...
       
}).
        execute
();
 
}

 @MetaData("{'TestCaseID':'TC-12346'}")
 @Test(description="a sample scenario", ...)

 
public void scenario2() {

        scenario
().
        given
("this is stpe-1",()-> step1()).
       
when("i perform step-2",()-> step2()).
        and("i also do step-3",()-> step3()).
       
then("expected something for scenario2",()->{
               
//write appropriate code or call method(s)...
       
}).
        execute
();
 
}
}

Major benefit is you can automate feature as is without modifying it. Most of the time we seen that the initial version doesn't mach to one that automated. Because it will have lot's of changes and made unreadable or not understandable by others.

मंगलवार, 31 मार्च 2020 को 5:20:36 पूर्व UTC-7 को, Arisa Ando ने लिखा:
Reply all
Reply to author
Forward
0 new messages