A simple example of FitNesse

Source: Internet
Author: User

Fixture Code

 Packageeg;ImportOrg.joda.time.DateTime; Public classJodatime {intYear ;  PublicString GetCurrentTime () {datetime datetime=NewDateTime (); returnstring.valueof (dateTime); }         Public intgetYear () {datetime datetime=NewDateTime (); year=datetime.getyear (); returnYear ; }         PublicString getstringyear () {datetime datetime=NewDateTime (); returnstring.valueof (Datetime.getyear ()); }         Publicstring Getyearandmonth (String string) {datetime datetime=NewDateTime (); returnString.valueof (Datetime.getyear ()) + string.valueof (datetime.getdayofmonth () +string); }}

Table code:

!***< Hidden!*< Classpath setup! define Test_system {slim}!path lib/*. jar*! " Import the background code package name "'!| here Import           | | eg               | | fitnesse.fixtures|*! "" Test Script "'!| Script|joda Time        | | Check   |get current time| | | Check|get year| | | $v =|get year| | $s =|get string year| | Check | Get Year and Month | 567| | | Check | Get Year and Month | $s | |

Table View and Result:

-------------------------------------------------------------------------------------------

Preparatory work:

(a) Import third-party jar packages, used here to Joda-time-2.3.jar

1. First put the Joda-time-2.3.jar into the. \fitnesse-master\lib below

2. In eclipse, follow the edit build Path

3. Modify the Build.xml file in the FitNesse project, below the yellow bottom section.

....<Targetname= "Compile-server"depends= "Stamp-version, resolve"Description= "Compile FitNesse sources">        <mkdirdir= "${classes.dir}" />        <Ivy:cachepathPathid= "Compile.classpath"conf= "Default"/>        <JavacSrcdir= "${src.dir}"Destdir= "${classes.dir}"Debug= "true"Source= "${min.java.version}"Target= "${min.java.version}"Includeantruntime= "false"encoding= "UTF-8">            <Classpath>                 <pathelement Path = "{Lib.dir}/joda-time-2.3.jar"/>                <PathrefID= "Compile.classpath"/>            </Classpath>        </Javac>        <CopyTodir= "${classes.dir}">            <Filesetdir= "${src.dir}">                <includename= "fitnesse/resources/**" />                <includename= "**/*.properties" />            </Fileset>        </Copy>    </Target>.... <Targetname= "Retrieve"depends= "Resolve"Description= "Copy dependencies to lib/, mainly for acceptance tests and IDE S">       <!--<delete dir= "${lib.dir}"/>-->        <Ivy:retrievepattern= "${lib.dir}/[artifact". [ext] "conf= "Standalone,default,test" />    </Target>....

4. Create a new Jodatime class in the FitNesse project eg, the code is the fixture code above

5. Open the command line, enter the FitNesse home directory, enter the ant run, and start the compilation

6. Create a new testpage in FitNesse, click the Edit button, enter the content (you can directly copy the table code above)

7. After clicking Save, click the Test button to start the test.

A simple example of FitNesse

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.