public abstract class SutController extends Object implements SutHandler
| Constructor and Description |
|---|
SutController() |
| Modifier and Type | Method and Description |
|---|---|
ExtraHeuristicsDto |
computeExtraHeuristics() |
void |
enableComputeSqlHeuristicsOrExtractExecution(boolean enableSqlHeuristics,
boolean enableSqlExecution) |
void |
execInsertionsIntoDatabase(List<InsertionDto> insertions)
Execute the given data insertions into the database (if any)
|
int |
getActionIndex() |
abstract List<AdditionalInfo> |
getAdditionalInfoList() |
abstract Connection |
getConnection()
If the system under test (SUT) uses a SQL database, we need to have a
configured connection to access it.
|
String |
getControllerHost() |
int |
getControllerPort() |
int |
getControllerServerPort() |
abstract String |
getDatabaseDriverName()
If the system under test (SUT) uses a SQL database, we need to specify
the driver used to connect, eg.
|
List<ExtraHeuristicsDto> |
getExtraHeuristics() |
abstract List<AuthenticationDto> |
getInfoForAuthentication()
If the application uses some sort of authentication, these details
need to be provided here.
|
abstract String |
getPackagePrefixesToCover()
A "," separated list of package prefixes or class names.
|
abstract SutInfoDto.OutputFormat |
getPreferredOutputFormat()
Test cases could be outputted in different language (e.g., Java and Kotlin),
using different testing libraries (e.g., JUnit 4 or 5).
|
abstract ProblemInfo |
getProblemInfo()
Depending of which kind of SUT we are dealing with (eg, REST, GraphQL or SPA frontend),
there is different info that must be provided.
|
DbSchemaDto |
getSqlDatabaseSchema()
Extra information about the SQL Database Schema, if any is present.
|
abstract List<TargetInfo> |
getTargetInfos(Collection<Integer> ids) |
abstract UnitsInfoDto |
getUnitsInfoDto() |
protected UnitsInfoDto |
getUnitsInfoDto(UnitsInfoRecorder recorder) |
void |
handleSql(String sql)
Calculate heuristics based on intercepted SQL commands
|
void |
initSqlHandler()
This is needed only during test generation (not execution),
and it is automatically called by the EM controller after
the SUT is started.
|
abstract boolean |
isInstrumentationActivated()
Check if bytecode instrumentation is on.
|
abstract boolean |
isSutRunning()
Check if the system under test (SUT) is running and fully initialized
|
void |
newAction(ActionDto dto)
As some heuristics are based on which action (eg HTTP call, or click of button)
in the test sequence is executed, and their order, we need to keep track of which
action does cover what.
|
abstract void |
newActionSpecificHandler(ActionDto dto) |
abstract void |
newSearch()
Re-initialize all internal data to enable a completely new search phase
which should be independent from previous ones
|
void |
newTest()
Re-initialize some internal data needed before running a new test
|
abstract void |
newTestSpecificHandler() |
void |
resetExtraHeuristics() |
void |
setControllerHost(String controllerHost) |
void |
setControllerPort(int controllerPort) |
abstract void |
setKillSwitch(boolean b) |
boolean |
startTheControllerServer()
Start the controller as a RESTful server.
|
boolean |
stopTheControllerServer() |
boolean |
verifySqlConnection()
Either there is no connection, or, if there is, then it must have P6Spy configured.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitresetStateOfSUT, setupForGeneratedTest, startSut, stopSutpublic final boolean startTheControllerServer()
public final boolean stopTheControllerServer()
public final int getControllerServerPort()
public final int getControllerPort()
public final void setControllerPort(int controllerPort)
public final String getControllerHost()
public final void setControllerHost(String controllerHost)
public void execInsertionsIntoDatabase(List<InsertionDto> insertions)
SutHandlerexecInsertionsIntoDatabase in interface SutHandlerinsertions - DTOs for each insertion to executepublic int getActionIndex()
public final void handleSql(String sql)
sql - command as a stringpublic final void enableComputeSqlHeuristicsOrExtractExecution(boolean enableSqlHeuristics,
boolean enableSqlExecution)
public final void initSqlHandler()
public final void resetExtraHeuristics()
public final List<ExtraHeuristicsDto> getExtraHeuristics()
public final ExtraHeuristicsDto computeExtraHeuristics()
public final DbSchemaDto getSqlDatabaseSchema()
getConnection()public final boolean verifySqlConnection()
public abstract void newSearch()
public final void newTest()
public final void newAction(ActionDto dto)
dto - the DTO with the information about the action (eg its index in the test)public abstract void newTestSpecificHandler()
public abstract void newActionSpecificHandler(ActionDto dto)
public abstract boolean isInstrumentationActivated()
public abstract boolean isSutRunning()
Check if the system under test (SUT) is running and fully initialized
How to implement this method depends on the library/framework used
to build the application.
In Spring applications, this can be done with something like:
ctx != null && ctx.isRunning(), where ctx is a field where
ConfigurableApplicationContext should be stored when starting
the application.
public abstract String getPackagePrefixesToCover()
A "," separated list of package prefixes or class names. For example, "com.foo.,com.bar.Bar". This is used to specify for which classes we want to measure code coverage.
Note: be careful of using something as general as "com." or "org.", as most likely ALL your third-party libraries would be instrumented as well, which could have a severe impact on performance.
public abstract List<AuthenticationDto> getInfoForAuthentication()
If the application uses some sort of authentication, these details need to be provided here. Even if EvoMaster can have access to the database, it would not be able to recover hashed passwords.
To test the application, there is the need to provide auth for at least 1 user (and more if they have different authorization roles). When EvoMaster generates test cases, it can decide to use the credential of any user provided by this method.
What type of info to provide here depends on the auth mechanism, e.g.,
Basic or cookie-based (using CookieLoginDto).
To simplify the creation of these DTOs with auth info, you can look
at AuthUtils.
If the credential are stored in a database, be careful on how the
method resetStateOfSUT is implemented.
If you delete all data with DbCleaner, then you will need as well to
recreate the auth details.
This can be put in a script, executed then with SqlScriptRunner.
null if
* none is necessarypublic abstract Connection getConnection()
If the system under test (SUT) uses a SQL database, we need to have a configured connection to access it.
This method is related to SutHandler.resetStateOfSUT().
When accessing a Connection object to reset the state of
the application, we suggest to save it to field (eg when starting the
application), and return such field here, e.g., return connection;.
This connection object will be used by EvoMaster to analyze the state of
the database to create better test cases.
null if the SUT does not use any SQL databasepublic abstract String getDatabaseDriverName()
org.h2.Driver.
This is needed for when we intercept SQL commands with P6Spynull if the SUT does not use any SQL databasepublic abstract List<TargetInfo> getTargetInfos(Collection<Integer> ids)
public abstract List<AdditionalInfo> getAdditionalInfoList()
public abstract ProblemInfo getProblemInfo()
Depending of which kind of SUT we are dealing with (eg, REST, GraphQL or SPA frontend), there is different info that must be provided. For example, in a RESTful API, you need to speficy where the OpenAPI/Swagger schema is located.
The interface ProblemInfo provides different implementations, like
RestProblem.
You will need to instantiate one of such classes, and return it here in this method.
public abstract SutInfoDto.OutputFormat getPreferredOutputFormat()
public abstract UnitsInfoDto getUnitsInfoDto()
public abstract void setKillSwitch(boolean b)
protected UnitsInfoDto getUnitsInfoDto(UnitsInfoRecorder recorder)
Copyright © 2016–2021. All rights reserved.