exampler.com/testing-com > Tools > Multi

Testing Foundations
Consulting in Software Testing
Brian Marick

 

Multi - Generating test ideas from expressions with booleans and relational operators

A test idea is a brief statement of something that should be tested. For example, if you're testing a square root function, one idea for a test would be "test a number less than zero". The idea is to check if the code handles an error case.

Test ideas are gotten in a number of ways. This program helps derive test ideas from expressions that contain boolean operators and relational operators. The rationale behind the program is described in my "Testing for Programmers" course notes, beginning with the slide titled "A Program for Finding Faults in Boolean Expressions", currently slide 22.

This program has a primitive command-line interface. Someday I will enter the 80's and put on a GUI. Then I'd enter the 90's and provide an applet interface, except it's the 00's and Java in the browser is going away. Here's what it looks like with the timeless interface:

% multi
Type in an expression.
'q' to quit.
> a && b < c
Test ideas for (a && (b<c)):
       a          (b<c)
   -----   ------------
    true   b barely < c
   FALSE           true
    true           b==c

> q

So, if the expression is inside a function foo(boolean a, int b, int c), these three test inputs might satisfy the test ideas:

That's pretty much all there is to it.

In this version, there's one major restriction. The expressions cannot contain duplicate names:

> (a && b) || (a && c)
Parse Error: 'a' appears twice in the expression. Duplicates aren't allowed yet.

Installation

Multi is written in Java. Stop now if you don't have Java on your machine.

  1. Fetch either the tar archive or the zip archive. Extract the files.
  2. You'll see two jar files: Multi.jar and Trace.jar. Put those in your CLASSPATH.
  3. Run the program with java com.testing.multi.Multi (The multi script will save you typing.)

After the first person asks, I'll package up the source into a tidy distribution.

The uppercase stuff

THIS SOFTWARE IS PROVIDED BY BRIAN MARICK ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL BRIAN MARICK OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 

Comments to marick@exampler.com