Your SlideShare is downloading. ×
0
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Fitnesse With Scala
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Fitnesse With Scala

2,127

Published on

My Knowledge session at Knoldus on Fitnesse with Scala

My Knowledge session at Knoldus on Fitnesse with Scala

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,127
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
22
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. FitNesse With Scala Meetu Maltiar Principal Consultant Email: meetu@knoldus.com Twitter:@meetumaltiar
  • 2. FitNesse It is an open-source automated framework created for software testing It is excellent tool for collaboration in software development enabling developers, testers and customers to collaborate by writing tests FitNesse is based on Ward Cunningham's framework for Integration Test (FIT) now developed by Robert C Martin
  • 3. FitNesse Getting Stared Download fitnesse-standalone.jar from fitnesse.org Starting Fitnesse is by executing the jar file: java -jar fitnesse-standalone.jar -p 9090 Note: Doing first time will create directories You can now access FitNesse on URL: localhost:9090
  • 4. FitNesse Overview WikiTests Slim Runner Fixtures System Under Test Customer readable Tests FitNesse Results
  • 5. FitNesse Overview.. FitNesse works by executing Wiki pages which call custom written Fixtures Fixtures act as a bridge between wiki pages and the System Under Test Fixtures can be written many programming languages like java, Scala...
  • 6. Tests And suites FitNesse has Suite. It is a collection of Tests. When we execute one Suite all tests are run in a Suite. For creating a TaxCalculationSuite, go to localhost:9090/TaxCalculationSuite. FitNesse is smart enough to open a new Suite page. Save it by not adding any contents.
  • 7. FitNesse Wiki Test To create FitNesse wiki test, hover on add button and select “Test” It will open a new test page. Provide TaxCalculationTest name for the Test for now, and save it.
  • 8. FitNesse Wiki Test Writing Wiki Test page is simple. We create wiki tables. Each row in a table is separated by a pipe character. For example a table header of id, name and age is created like this |id|name|age|
  • 9. FitNesse Wiki Test For TaxCalculation test we want to calculate tax on annual salary. Here is a simple rule of Tax. If annual income is more than 100,000 it is 15%, or else it is 10%. The test in FitNesse Wiki must provide input to Fixture code in Scala and we must assert to compare output matched with actual results. |the tax for annual income|200000|is|30000|
  • 10. FitNesse Wiki Test |the tax for annual income|200000|is|30000| is a specification of intent from a Tester or customer. Now, we can build support around this. For us developers, we need to specify jars, classes and Fixture class that we will be executing methods on. For finding libraries and classes we use !path in FitNesse wiki. !define TEST_SYSTEM {slim} !path /Users/meetumaltiar/.sbt/boot/scala-2.9.1/lib/scala-library.jar !path ../lib/fitlibrary-20080812.jar Add above content at top of the test page and save. You will notice proper classpath set.
  • 11. FitNesse Wiki Test We will have to load a specific class on which the methods will be executed. If our Fixture scala class is TaxCalculationFixture in com.knoldus.fixture package. Then, we will have to write following in FitNesse Wiki |import| |com.knoldus.fixture| !|script | TaxCalculationFixture|
  • 12. FitNesse Wiki Test We need to write our test having assertions. We will use DoFixture semantics in our Wiki. |import| |com.knoldus.fixture| !|script | TaxCalculationFixture| |the tax for annual income|200000|is|30000| Above definition means that we have a method in scala class TaxCalculationFixture: def theTaxForAnnualIncomeIs(annualIncome: Double, tax: Double): Boolean
  • 13. FitNesse Wiki Test |import| |com.knoldus.fixture| !|script | TaxCalculationFixture| |the tax for annual income|200000|is|30000| If we use DoFixture then each odd column is a part of a method and each even column is parameter to the method. If method is written in camel case we can write method in FitNesse wiki like a DSL
  • 14. Completed Wiki Test !define TEST_SYSTEM {slim} !path /Users/meetumaltiar/.sbt/boot/scala-2.9.1/lib/scala-library.jar !path ../lib/fitlibrary-20080812.jar |import| |com.knoldus.fixture| !|script | TaxCalculationFixture| |the tax for annual income|200000|is|30000| |the tax for annual income|100000|is|10000|
  • 15. Using DoFixture To start with add a dependency of fitnesse and fitlibrary in your SBT project containing the fixture libraryDependencies += "org.fitnesse" % "fitnesse" % "20121220" libraryDependencies += "org.fitnesse" % "fitlibrary" % "20080812"
  • 16. DoFixture DoFixture is a Scala class extending DoFixture class in FitLibrary DoFixture is a Fixture and acts as a bridge between wiki FitNesse tests and System under test Each odd column in table in wiki corresponds to part of method definition. Each even column has parameters we can pass in function defined in a DoFixture
  • 17. TaxCalculationFixture package com.knoldus.fixture import fitlibrary.DoFixture import com.knoldus.tax.TaxCalculatorService class TaxCalculationFixture extends DoFixture { val taxCalculatorService = new TaxCalculatorService def theTaxForAnnualIncomeIs(annualIncome: Double, tax: Double) = taxCalculatorService.getTaxForAnnualIncome(annualIncome) == tax }
  • 18. TaxCalculatorService package com.knoldus.tax class TaxCalculatorService { def getTaxForAnnualIncome(annualIncome: Double): Double = (annualIncome <= 100000.0) match { case true => annualIncome * 0.10 case false => annualIncome * 0.15 } }
  • 19. Running Tests We can execute an individual FitNesse wiki Test We can execute all tests by running a Suite. Running a suite will run all tests in a Suite We can organize Suites depending on behavioral design of our application.
  • 20. Code is available on Knoldus Github: https://github.com/knoldus/ScalaFitnesse Thanks!!

×