Skip to main content

FIT and Eclipse: Testing with the Extended FIT Eclipse plug-in

Getting a handle on the basics

Vishnu Vettrivel (vishnu@punditlabs.com), Principal Consultant, PunditLabs
Vishnu Vettrivel is the Principal Consultant at PunditLabs, which specializes in enterprise consulting and technology, and he has many years of experience in architecting, designing, and developing mission-critical enterprise applications. Having worked extensively for Fortune 50 clients, he has helped craft strategic technical plans for many emerging technologies. You can reach him at vishnu@punditlabs.com.

Summary:  Learn the basic Framework for Integrated Tests (FIT) concepts and, through the use of the Extended FIT Eclipse plug-in, begin the process of testing FIT tables for Eclipse developers. This article, the first in a two-part series, introduces you to FIT and shows you how to use it within an Eclipse-based environment.

View more content in this series

Date:  30 May 2006
Level:  Introductory
Activity:  3258 views
Comments:  

Since the days of mainframe computers, software engineers have had two main concerns: First, how does business communicate what it requires from an application and, second, how do engineers validate that they're building the correct software for the business need? Various methodologies and frameworks have appeared over the years to address these concerns, but not until the Framework for Integrated Tests (FIT) has a method been able to address them in a simple and intuitive way.

FIT is a general-purpose, open-ended framework that you can easily extend for expressing various sorts of tests. This article shows you how to use FIT in conjunction with Eclipse to solve several problems in software development. I begin by giving you a brief look at what FIT does to solve the problems inherent in software engineering.

FIT facilitates communication among the various stakeholders and developers in a business, focusing precisely on what must be done. This functionality helps everyone avoid unclear business needs and helps ensure that developers solve the right business problem. Also, FIT supports the inevitable restructuring of code as the system evolves, reducing the difficulty of maintaining, extending or changing code, as well as code bloat and software entropy. Finally, FIT increases overall software quality by ensuring that the team knows immediately when a component has been completed as well as when completed work has been mistakenly broken.

FIT and JUnit

If you use JUnit, the all-important question is, Do I have to stop writing JUnit test cases? The answer is a resounding No. FIT isn't intended to supplement JUnit testing; rather, it functions at a higher level -- the level of integration testing (see Figure 1).


Figure 1. The FIT process flow
FIT process flow

You can still develop JUnit tests. But in addition, you'll create FIT tests using FIT tables.


FIT and FIT tables

For JUnit, it was a test case. For the IBM Rational Unified Process® (RUP®), it was a use case. For FIT, it's a table. Tables play a pivotal role in delivering on the FIT promise of increased communication among stake holders, software agility, and software stability.

Tables are a simple and effective way to communicate, whether they're the final scores of a baseball game or the stock prices in your daily newspaper. For this reason, the creators of FIT have chosen tables as the weapon of choice for allowing users to communicate software behavior through examples, which reduces ambiguity and puts the onus on the user to clearly define the software system.

Agility -- allowing change to happen -- is of key importance to modern software systems. The increasing rate of competition forces business users to keep adding more features and functionalities. FIT testing helps increase agility by defining changes and ensuring that no software modifications break previously satisfied requirements. FIT tables serve as a mechanism for conveying the results of the software developed by acting as a guiding light in the development process and focusing on business value.

However, with increased agility and change comes the increased risk of losing stability. FIT tables help restore the balance required of a System Under Test (SUT) by making sure that any changes to the underlying system -- including refactoring and enhancements -- are visually conveyed immediately to the various stakeholders of that system.


Testing calculations with FIT

Testing calculations according to a given business rule is an important part of software testing. Business needs are communicated in the form of tables and concrete examples help you understand what's required.

Example: FIT calculation table

The business rule for the calculation test in this example is:

A US scholarship worth 500 hundred dollars is awarded to students whenever their Scholastic Assessment Test (SAT) score is at least 2000, and for every 100 points over 2000. The sample data in the table is used to model the correlation between the SAT score and the scholarship awarded for several cases. For example, when the score is 2300, the scholarship is 2000 US dollars.

Table 1 is an example of a FIT table that models the expected behavior of this business rule. That rule calculates the scholarship that students receive based on their SAT scores.


Table 1. FIT calculation using a ColumnFixture table
CalculateScholarship
ScoreScholarship()
10000
19990
2000500
2050500
21001000
22001500
23002000
23502000
24002500

The first row in the table shows the name of the fixture to be tested. The fixture class acts as the driver to determine how the sample data sets in the table are to be tested against the SUT. In this example, the fixture is CalculateScholarship.

Because this example involves a ColumnFixture table, the second row identifies the names of the given and the calculated field columns. In this example, the Score column refers to the input values, and the Scholarship() column refers to the expected calculated result.


Create a FIT fixture for the ColumnFixture table

To make the framework work with Table 1, you must create a fixture, or an intermediary Test Adapter class that tells FIT how to talk to your software. Listing 1 shows the CalculateScholarship fixture.


Listing 1. The CalculateScholarship fixture
public class CalculateScholarship extends ColumnFixture {

            public int score;

            public int scholarship(){

                        ScholarshipSystem scholar  = new ScholarshipSystem();

                        return scholar.calculateScholarship(score);

	  }

}

This fixture invokes the SUT ScholarshipSystem class shown in Listing 2, and then invokes the calculateScholarship() method on it.


Listing 2. The ScholarshipSystem class
public class ScholarshipSystem  {

    public int calculateScholarship(int score){

    	int scholarship  = 0;
    	
    	if(score<2000)
    		return scholarship;
    	else
    		scholarship = 500;
    	
    	scholarship = scholarship + ((score - 2000)/100) * 500;
    	
    	return scholarship;
    }

}

You can extend different types of fixtures depending on what you're testing. In the example above, I used ColumnFixture to map the columns in the table to variables and methods in the fixture.

The two columns in the table correspond to variables in the fixture. The second column, which contains the expected result, corresponds to the scholarship() method in the fixture. To calculate the answer, I used the ScholarshipSystem class as the SUT.


Testing with FIT in Eclipse

To demonstrate how you can use FIT in an Eclipse environment, I used the Extended FIT Eclipse plug-in, which provides a simple user interface (UI) for loading FIT input and output files. This plug-in is based on the basic FIT Library plug-in.

Installing the Extended FIT Eclipse plug-in

To install the Extended FIT Eclipse plug-in, complete these steps:

  1. Download the core FIT Eclipse plug-in.
  2. Extract the .zip file contents, and copy the .jar file into the Plugins folder of your Eclipse installation.
  3. Download the Extended FIT Eclipse plug-in.
  4. Copy the .jar file to the Plugins folder of your Eclipse installation.
  5. Restart Eclipse.

You should now see a new FIT menu as well as a Run FIT toolbar button (see Figure 2). If you do, you've successfully installed the Extended FIT Eclipse plug-in.


Figure 2. The Extended FIT plug-in installed in Eclipse
Extended FIT plug-in

The Extended FIT Eclipse plug-in comes bundled with the FIT .jar file, so you don't need to install the FIT .jar file separately for running tests. However, to develop your fixtures, you might need to add the FIT .jar file to your build path.

Testing other kinds of fixtures

You can use the approach shown here for testing calculations using FIT tables and fixtures to test other FIT tables. For example, you use the ActionFixtures fixture to test business process flow, while you use the RowFixtures fixture to test the results of an expected search or a query. The only difference in testing these kinds of fixtures using the Extended FIT Eclipse plug-in is that the fixture you write would extend a different type of Base Fixture class.

Using the Extended FIT Eclipse plug-in

To use the Extended FIT Eclipse plug-in, you need three files:

  • An input .html file that contains all the input FIT tables
  • An output .html file that contains the results of the FIT test run
  • A separate .jar file that contains all your custom fixture classes

Note: When creating custom fixture classes, be sure to bundle them into a .jar file using your favorite build tool. The Extended FIT Eclipse plug-in expects the location of this .jar file to run FIT tests.

When you have all the required files for the Extended FIT Eclipse plug-in, you can start running FIT tests by completing the following steps:

  1. Click Run FIT.
  2. Click Browse i/p to add the name of your input file.
  3. Click Browse o/p to locate your output file.
  4. Click Browse fixture Jar to locate your fixture .jar file.
  5. Click Run FIT.

FIT takes an .html file as input; as a result, the input file names are configured to be the same (see Figure 3).


Figure 3. Running tests using the Extended FIT Eclipse plug-in
Running tests

Extended FIT Eclipse plug-in functioning

The Extended FIT Eclipse plug-in for Eclipse functions as a simple wrapper that acts as a delegate to the underlying FIT library. When you click Run FIT, the Extended FIT Eclipse plug-in invokes and runs the FIT FileRunner class by passing the selected input and output files as parameters to it. The FIT FileRunner class in turn parses the input file and writes the results of the FIT run into the output file that you selected. If everything ran without a glitch, you should have the results of the run displayed in a window.


Looking ahead

In this article, you saw how FIT allows users and engineers to bridge the communication gap regarding their software. By creating tangible examples, users can give engineers a clear vision of what they must build. You also saw how FIT and Eclipse come together in a perfect way by allowing developers to write fixtures and run FIT tables to verify their software. By extending the core FIT Eclipse plug-in, you saw how it's possible to use Eclipse to perform FIT testing for calculation-based rules, which can easily be applied to other forms of FIT testing, as well.

In the next article in this series, you'll see how the Extended Eclipse FIT plug-in was built. You'll also learn how FIT was used to test the plug-in itself in Eclipse's Plug-in Development Environment (PDE).


Resources

Learn

Get products and technologies

  • Eclipse V3.1: Download a free trial version of Eclipse V3.1.

  • FIT Eclipse plug-in: Download and find more information about the core FIT Eclipse plug-in.

  • Extended FIT Eclipse plug-in: Download and find more information about the Extended FIT Eclipse plug-in.

  • IBM trial software: Build your next development project with IBM trial software, available for download directly from developerWorks.

Discuss

  • AIX and UNIX forums: Discuss and participate in the developerWorks AIX and UNIX forums.

  • developerWorks blogs: Participate in developerWorks blogs and get involved in the developerWorks community.

About the author

Vishnu Vettrivel is the Principal Consultant at PunditLabs, which specializes in enterprise consulting and technology, and he has many years of experience in architecting, designing, and developing mission-critical enterprise applications. Having worked extensively for Fortune 50 clients, he has helped craft strategic technical plans for many emerging technologies. You can reach him at vishnu@punditlabs.com.

Comments



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX
ArticleID=125319
ArticleTitle=FIT and Eclipse: Testing with the Extended FIT Eclipse plug-in
publish-date=05302006
author1-email=vishnu@punditlabs.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers