Scenario: Modular definition of the capabilities and limitations of fitnesse Test Cases

Source: Internet
Author: User

First, let's popularize the concept. What isFitnesseLet's hear about the. Net version of Cucumber's founder asak helles ø y.FitnesseComparison with cucumber:

Fit/FitnesseAnd cucumber both perform acceptance tests written in advanced languages. Fit only recognizes HTML, while fitnesse simplifies the process of writing tests by providing wiki syntax. In fit/fitnesse, all tests are presented as tables.
Fitnesse has the advantage of Wiki support over cucumber.

Link: http://www.infoq.com/cn/news/2009/11/interview-cucumber-for-dotnet

Requirements for instantiationFitneeseDescription:

FitnesseAll functions covered by the suite (live documentation) have passed complete system tests and user acceptance tests, and no defects have been found when the production environment is launched. Errors other than core computing components were discovered during system testing. The reason why the business personnel think that the user acceptance test is very good is that when a calculation error occurs, we are very sure that the fundamental problem lies in the upstream of the computing code. With fitnesse, it is easy to diagnose the root cause of a defect, so that it can be delivered to the production environment more efficiently and quickly.

Link: http://www.douban.com/group/topic/35316487/

1. What is scenario?

Fitneese's slim userguide introduces scenario

The original article introduces scenario as follows:

A scenario table is a table that can be called from other tables; namely script table and demo-table.

The format of a scenario table is the same as the format of a script table, but with a few differences. You can see a scenario table in action here.

Scenario is a table that can be called by script table and demo-table.

As a result, many people have reported great expectations for scenario, hoping to use scenario modular encapsulation of test steps.

2. Scenario capability display

The following is a scenario demo I wrote in combination with the script sample and scenario sample:

Wiki text:

?
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 !define TEST_SYSTEM {slim}!path classes |import||fitnesse.slim.test| !4 Define scenario checklogin: logon and check results| scenario | checkLogin | u || p || ensure || logged || @{ensure} | login with username | @{u} | and password | @{p} || check @{logged} | login message | @{u} logged in. || show | number of login attempts | !4 Create a script instance. scenario is called later for this instance.| script | login dialog driver | Bob | xyzzy | !4 Invoking a scenario from a !-DecisionTable-!| checkLogin || u | p | ensure | logged || Bob | xyzzy | ensure |  || Bob | zzyxx | reject | not || Cat | xyzzy | reject | not | !4 Invoking a scenario from a !-ScriptTable-!| script || checkLogin | Bob || zzyxx || reject || not || checkLogin | Bob || xyzzy || ensure ||  | !4 Original Script example| script | login dialog driver | Bob | xyzzy || login with username | Bob | and password | xyzzy || check | login message | Bob logged in. || reject | login with username | Bob | and password | bad password || check | login message | Bob not logged in. || check not | login message | Bob logged in. || ensure | login with username | Bob | and password | xyzzy || note | this is a comment || show | number of login attempts || $symbol= | login message | The fixture for this table is:{{{public class LoginDialogDriver {  private String userName;  private String password;  private String message;  private int loginAttempts;   public LoginDialogDriver(String userName, String password) {    this.userName = userName;    this.password = password;  }   public boolean loginWithUsernameAndPassword(String userName, String password) {    loginAttempts++;    boolean result = this.userName.equals(userName) && this.password.equals(password);    if (result)      message = String.format("%s logged in.", this.userName);    else      message = String.format("%s not logged in.", this.userName);    return result;  }   public String loginMessage() {    return message;  }   public int numberOfLoginAttempts() {    return loginAttempts;  }} }}}

Test Case page:

Click "test" to execute:

Expand the test result of decisiontable calling scenario:

Expand the test result of scripttable calling scenario:

Now we can see that scenario can encapsulate the script step, get a module name, and then call it using decisiontable or scripttable.

3. Limitations of Scenario

Note the line before calling scenario:

The purpose is to create a script instance before calling scenario.

If this sentence is removed and then executed, the result is as follows:

Try again and insert the statement for creating the script instance to scenario:

?
123456 !4 Define scenario checklogin: logon and check results| scenario | checkLogin | u || p || ensure || logged || Script | Login Dialog driver | Bob | Xyzzy | <-- this is a newly added statement used to create a script instance.| @{ensure} | login with username | @{u} | and password | @{p} || check @{logged} | login message | @{u} logged in. || show | number of login attempts |

Save and run the test:

4. What should I do if I am not satisfied?

I also want to use scenario to encapsulate tabletable, such as the tabletable defined by restfixture,
Stackoverflow.com, the most famous Chinese software development Q & A website, is also asking:
Can I make a scenario of restfixture table in fitnesse ?, Or is there another way to make reusable components?

I am going to modify the fitneese code so that scenario can directly encapsulate scripttable and tabletable. Please follow the blog ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.