Step 1: Edit the FrontPage in FitNesse
Remove the default content from the FrontPage and prepare it for global settings. Click on the Edit button of the FrontPage and remove the existing content. Add the contents as shown in the below screenshot. It has the test Case page which we are going to test on FitNesse server, Set Up page which is used to import the Java class fixtures, Tear down page to act after the test is executed successfully and the most important one is the setting up of the Java Class path and definition of the various FitNesse variables. Once these four pages are defined, click on the save button to generate these FitNesse pages.
Step 2: Creating and defining the page properties for 4 FitNesse Pages
This step involves creating and saving above 4 FitNesse pages and defining their properties. “Test Cases” page has page type as Test while the remaining 3 FitNesse test pages have page type as Static.
Step 3: Adding content to root page in FitNesse
Root page is the very important page in FitNesse as all the system variable definitions are defined here along with the classpath for Java fixtures. For the current example to test the mathematics operations, we need to define the Java classpath where fixtures are located. Also we need to define basic FitNesse variables such as TEST_SYSTEM as slim (Testing engine used), COLLAPSE_SETUP as true and COLLAPSE_TEARDOWN as true. Below screenshot demonstrates how to define a variable and classpath in FitNesse as script.
Step 4: Adding content to Setup page in FitNesse
Click on the Edit button and add the script as shown in the below screenshot. This script imports the package where Java class fixtures are found. In the current example we are going to develop and compile Java classes into package name as test.
Step 5: Adding content to Teardown page in FitNesse
FitNesse test scripts present on the Teardown page are executed after any FitNesse test or entire suite is executed successfully. For example, if you need to clear the database after current test is completed in order to execute the next test. It is best to call that fixture directly by writing a script on this page. Below screenshot demonstrates how a TearDown FitNesse page looks like.
Step6: 写一个Java程序计算1+5=6
Step7: 写testcase
root 一般放置全局变量使用