Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Even though one of the objectives of GreenPepper Image Added is to create a common language between the business experts and the development team, there will always be a certain degree of difference between the natural language and the programing language. Hence comes the reason for having fixtures. Fixtures are the glue between the business expert examples and the software being developed. When running the table, GreenPepper Image Added uses a fixture to mediate between the example expressed in the table and the system under test.

...

Note

When using the humanized version of fixture naming, you must use Import Tables.

Explicit package won't work ex: |list of | com.xyz.stuff.the fixture name|

...

Suffix example
rule forbank account fixture
......

and

rule forbank account
......

will both match

Code Block
languagejava
public class BankAccountFixture{
...
}

Constructor

A fixture can receive parameters during it's construction. You must have a public constructor that matches the numbers of parameters.

When no parameters are specified in the example, the fixture class must have a public constructor without parameters.

Empty constructor example
rule forbank account
......
Code Block
languagejava
public class BankAccountFixture {
   public BankAccountFixture()
   { ... }
}
An example with two parameters
rule forpoker tableante5$max bet

100$

...... 
Code Block
languagejava
public class PokerTableFixture {
   public PokerTableFixture(Ammount ante, Ammount maxBet)
   { ... }
}

Rule validation (Rule For)

Definition

Definition

The RuleForInterpreter is used to express concrete and measurable business rules.
During the execution of the specification, GreenPepper compares the values returned by the system under development against the expected values defined by the Business Expert.

Image Added

  • The first row of the table indicates the set of rules to be tested by GreenPepper.
  • The next row is called the header row and serves to distinguish the given values and the expected values. Given values serve as inputs to the system, whereas expected values serve as comparison values against values that are actually returned by the system. When a column header ends with special characters ? or (), it denotes an expected value.
  • Finally, the remaining rows capture the examples. They are the executable test rows.

Specific keywords for expected values

GreenPepper offers a list of useful keywords to support the Business Expert.

Empty cellsWhen a test cell is left blank, GreenPepper only shows the returned value
errorWhen you expect an error, specify it in the cell to test that particular behavior

Coloring

GreenPepper will visually show the test result by coloring each testing cell:

Panel
bgColorlightgreen
titleBGColorlightgreen
titleGreen
borderStyledashed

 When the expected value matches the returned value, the RuleForInterpreter colors the cell as "right" by coloring it green.

Panel
bgColor#f08080
titleBGColor#f08080
titleRed
borderStyledashed

If the values don't match, the RuleForInterpreter colors the cell as "wrong" in red.

Panel
bgColor#f0e68c
titleBGColor#f0e68c
titleYELLOW
borderStyledashed

If the system encounters an execution error, the cell is colored yellow and GreenPepper provides information about the error.

Panel
bgColorgrey
titleBGColorgrey
titleGrey
borderStyledashed

If no expected value is specified in a test, the RuleForInterpreter colors the cell in gray.

Here is an example of cell coloring:

Input Table:

rule forcalculator 
xysum?product()quotient?
1001000
639-5 

Output Table:

rule forcalculcator 
xysum?product()quotient?
100100

0


java.lang.ArithmeticException: / by zero
com.greenpepper.fixture.calculator.Calculator.quotient(Calculator.java:63)
639Expected: -5 Received: 182

Writing fixtures for Rule tables

As we've seen in Rule For definition, a table of rules is used to express business rules of the application under development.

A fixture for a table of rules defines how the specific given and expected columns of a rule table are mapped to the system under development.

This page shows the fixture code that supports the examples introduced in the Writing a Rule For specification documentation.

List Validation (List of, Set of, Superset of, Subset of)

...