Dashboard > Documentation > Documentation > Excel Test Data Format
  Documentation Log In | Sign Up   View a printable version of the current page.  
  Excel Test Data Format
Added by Adam Skogman, last edited by Adam Skogman on Feb 04, 2006  (view change)
Labels: 
(None)

Work in progress!

See also:

  • Excel Database Fixture Format - detailed information on how to put database fixture data in an Excel file.
  • [Excel LDAP Fixture Format] - detailed information on how to put database fixture data in an Excel file.

Introduction

When you use Excel for data, your testSomething() mtehod in your test case gets run one time for each row of Excel data.

How to use Excel

Your test case must inherit from one of the data-driven base classes in DDSteps.

If you inherit from this base classes, you will get data from Excel without having to do anything special in your code:

  • org.ddsteps.testcase.support.DDStepsExcelTestCase (plain unit test base class).

If you want more control over the data loading, or want to use Spring Framework, you use one of these base classes:

  • org.ddsteps.DdTestCase
  • org.ddsteps.spring.DdSpringTestCase

TODO See doc on how to make test cases data driven.

Concepts

File Name = Test Class Name

You have one Excel file per Test Case class.
Example: Your implementation class is com.example.MyClass and your test case class is com.example.MyClassTest (as is pretty much standard). Then you name the Excel file MyClassText.xls.

Same Package as the Test Class

Put the Excel file in the same package as your test case class.
The most common way is to put the Excel file right next to the test case .java file on the harddrive. This is quite easy to do in Eclipse etc. DDSteps uses the classloader to load the Excel file, so you can have more than one "source folder" in Eclipse and put the Excel files in another source folder (if you like to put non-java stuff in an "etc/resources" folder) as long as they are in the same package.

Method Same = Sheet Name

For each test method testSomething() in your test case, you have one sheet in your Excel file.
The method name is the same as the sheet name. This is how DDSteps finds which sheet to get data from. DDSteps only looks at the sheet name, not at the contents of the sheet (like big headings or stuff like that) when looking for the sheet for a test method.

MyClassTest.java
public void testCompare() throws Exception {...}
public void testNull() throws Exception {...}

Sheet Format

The rows of a sheet is divided into parts:

  1. Free text - information that you want, is not read by DDSteps.
  2. The property headers - the names of properties that DDSteps will inject data into.
  3. The data - the data, for each row here your test method will be run once.
  4. More free text - typically data rows that are under construction and that you don't want to run but are saving for later.

DDSteps separates the sheet into these parts by looking for three dashes in the A column. If you want to write you own Excel file, you write '---. Using the template is highly recommended.

Free text

Here you typically put a big header and maybe document which properties are available.

Headings mean nothing!

DDSteps matches the sheet name against the method in your test class. It does not look at your heading. This is a common gotcha.

Property Headings

Excel Template (Documentation)

Are you enjoying Confluence? Please consider purchasing it today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2 Build:#512 Apr 26, 2006) - Bug/feature request - Contact Administrators