Fundamentals 7 min read

EvoSuite Overview: Installation, Maven Configuration, and IDEA Plugin Usage

This article introduces EvoSuite, an open‑source tool for automatically generating JUnit test suites, explains how to configure it with Maven (including the required pom.xml entries), describes essential command‑line options, and provides step‑by‑step instructions for installing and using the EvoSuite plugin in IntelliJ IDEA, supplemented by practical examples and coverage analysis.

转转QA
转转QA
转转QA
EvoSuite Overview: Installation, Maven Configuration, and IDEA Plugin Usage

EvoSuite is an open‑source tool jointly developed by the University of Sheffield and other institutions that automatically generates JUnit‑compatible test suites for Java code, greatly improving testing efficiency while still requiring human validation of the generated tests.

The tool can be run via several methods, including a command‑line interface, Eclipse and IntelliJ IDEA plugins, and Maven integration. The article focuses on Maven and IDEA usage.

Maven – EvoSuite Plugin Configuration

The following pom.xml fragment adds the required JUnit dependency and configures the EvoSuite Maven plugin:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.evosuite.plugins</groupId>
            <artifactId>evosuite-maven-plugin</artifactId>
            <version>1.0.6</version>
            <scope>compile</scope>
        </plugin>
    </plugins>
</build>

Key command‑line options include:

prepare : runs both EvoSuite and existing tests (e.g., mvn evosuite:prepare test ).

compile : ensures classes are compiled before test generation.

-DmemoryInMB=2000 : allocates 2000 MB of memory.

-Dcores=2 : uses two CPU cores for parallel generation.

-Dcuts=your.package.ClassName : limits generation to the specified class (multiple classes can be comma‑separated).

-DtargetFolder=src/test/java/evosuite : specifies where generated tests are placed.

evosuite:generate : triggers test generation.

evosuite:export : copies generated tests from the hidden .evosuite directory to the target folder.

evosuite:clean : removes all data in the .evosuite directory.

Example Maven command:

mvn compile evosuite:generate -Dcuts=demoTest.testService.demoTwoService evosuite:export -DtargetFolder=src/main/java/testcase

The generated files include demoService_ESTest (the test class) and demoService_ESTest_scaffolding (a base class for initialization).

IntelliJ IDEA – EvoSuite Plugin Installation and Use

Open Settings/Preferences → Plugins → Browse Repositories, search for “EvoSuite Plugin”, and install it.

Restart IDEA.

Right‑click a source file and select Run EvoSuite to open the parameter dialog.

Specify the same options as in Maven (memory, cores, target folder, etc.) and run.

Typical IDEA screenshots are shown in the original article.

Examples and Coverage

Two example classes ( demoTwoService.java and demoService.java ) are used to demonstrate generated test cases. The first example yields an 84 % coverage, while the second shows missing branches (e.g., a==0 or b==0 ) and a lower coverage percentage. Screenshots of the generated tests, console output, and coverage reports are included.

The article concludes that EvoSuite can significantly speed up test creation and improve coverage, but the generated tests still need manual review because the tool cannot fully replace human judgment.

Javaautomated testingMavenIntelliJ IDEAJunitEvoSuite
转转QA
Written by

转转QA

In the era of knowledge sharing, discover 转转QA from a new perspective.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.