Mock Class Generation: in Dynamic Symbolic Execution

uta logo
We generate mock classes in order to generate test cases, specially in which the code under test uses multiple interfaces, annotations or reflections. We have implemented our technique to generate mock classes in our dynamic symbolic execution engine - Dsc.

Survey of open-source subject applications

We have surveyed around 35 open source Java applications to find out how often such user code occur where mock class generation will be needed. The summary of our survey can be found here.


The summary of our experiments can be found here.

How to run the Experiments

Download the binary relase of Dsc from the downloads section below.

Let's say, the directory: c:\java\dsc\ contains the contents of the Dsc binary distribution zip file. Create a configuration file conf_mock.txt in the same directory. Add the following entries in the file: These two options are enough for running all the examples in this page. The config section below contains more useful configuration options for generating mock classes with Dsc. After creating the configuration file, download our experiments from the table in the downloads section.

How to run the Java examples
How to run the C# examples

Configuring options

MOCK_MODE = true
MOCK_MODE must be set to 'true' to enable mock class generation.
Approximate timeout for each solver query (milliseconds), 0 = no timeout. Usually mock class generation takes more time than trivial test case generation. If you do not get any result from Dsc try with increased timeout.
Maximum number of mock classes that Dsc will generate.
OUT_DIR_BIN = generated-bin
Dsc writes Java byte-code into this directory, i.e., mock classes. Set the value to a directory where the mock classes will be generated.
Please see how to run and configure Dsc if needed.

Downloads contains the binary release (together with all required third-party libraries) of Dsc that we have used to run our mock class experiments.

Subject Java Programs C# Programs
Motivating Examples
Example 43.7 kB 377 kB
Multiple Interface 45.1 kB 386 kB
Annotation 44.9 kB 380 kB
IsAssignableFrom (Reflection) 45.9 kB 388 kB
IsInstance (Reflection) 46.6 kB 397 kB
Real World Examples
ApacheActiveMQ 48.6 kB 259 kB
JaxLib 41.3 kB 171 kB
Jme (JMonkeyEngine) 43.0 kB 239 kB

Publications on Mock Class Generation


Mainul Islam, Christoph Csallner

back to top