public interface SutHandler
| Modifier and Type | Method and Description |
|---|---|
InsertionResultsDto |
execInsertionsIntoDatabase(List<InsertionDto> insertions,
InsertionResultsDto... previous)
Execute the given data insertions into the database (if any)
|
MongoInsertionResultsDto |
execInsertionsIntoMongoDatabase(List<MongoInsertionDto> insertions) |
default Object |
executeRPCEndpoint(String json)
execute an RPC endpoint with evomaster driver
|
default void |
extractRPCSchema()
execute an RPC endpoint with evomaster driver
|
List<DbSpecification> |
getDbSpecifications()
If the system under test (SUT) uses a SQL database, we need to have a
configured DbSpecification to access/reset it.
|
default Object |
getMongoConnection() |
default Object |
getRPCClient(String interfaceName)
return an instance of a client of an RPC service.
|
default boolean |
handleLocalAuthenticationSetup(String authenticationInfo)
authentication setup might be handled locally.
|
default boolean |
mockDatabasesWithCustomizedHandling(String mockDatabaseObjectDtos,
boolean enabled)
a method to employ customized mocking for database
|
default boolean |
mockRPCExternalServicesWithCustomizedHandling(String externalServiceDtos,
boolean enabled)
a method to employ customized mocking of RPC based external services
|
default void |
registerOrExecuteInitSqlCommandsIfNeeded()
register or execute specified SQL script for initalizing data in database
|
default boolean |
resetCustomizedMethodForMockObject()
a method to reset mocked external services with customized method
|
default void |
resetDatabase(List<String> tablesToClean)
reset database if the smart db cleaning is employed
|
void |
resetStateOfSUT()
Make sure the SUT is in a clean state (eg, reset data in database).
|
default void |
setupForGeneratedTest()
There might be different settings based on when the SUT is run during the
search of EvoMaster, and when it is later started in the generated tests.
|
String |
startSut()
Start a new instance of the SUT.
|
void |
stopSut()
Stop the SUT.
|
default void setupForGeneratedTest()
String startSut()
Start a new instance of the SUT.
This method must be blocking until the SUT is initialized.
How this method is implemented depends on the library/framework in which
the application is written.
For example, in Spring applications you can use something like:
SpringApplication.run()
void stopSut()
Stop the SUT.
How to implement this method depends on the library/framework in which
the application is written.
For example, in Spring applications you can save in a variable the ConfigurableApplicationContext
returned when starting the application, and then call stop() on it here.
void resetStateOfSUT()
Make sure the SUT is in a clean state (eg, reset data in database).
A possible (likely very inefficient) way to implement this would be to
call stopSUT followed by startSUT.
When dealing with databases, you can look at the utility functions from
the class DbCleaner.
How to access the database depends on the application.
To access a java.sql.Connection, in Spring applications you can use something like:
ctx.getBean(JdbcTemplate.class).getDataSource().getConnection().
InsertionResultsDto execInsertionsIntoDatabase(List<InsertionDto> insertions, InsertionResultsDto... previous)
insertions - DTOs for each insertion to executeprevious - an array of insertion results which were executed before this executionMongoInsertionResultsDto execInsertionsIntoMongoDatabase(List<MongoInsertionDto> insertions)
default Object getRPCClient(String interfaceName)
return an instance of a client of an RPC service.
This method must be blocking until the SUT is initialized.
This method is only required when the problem is RPC for the moment, otherwise return null
might change string interfaceName to class interfaceinterfaceName - a full name of an interfacedefault Object executeRPCEndpoint(String json) throws Exception
execute an RPC endpoint with evomaster driver
json - contains info of an RPC endpointExceptiondefault void extractRPCSchema()
execute an RPC endpoint with evomaster driver
TODO remove this later if we do not use test generation with driverdefault boolean handleLocalAuthenticationSetup(String authenticationInfo)
authentication setup might be handled locally. then we provide this interface to define it.
authenticationInfo - info for the authentication setupList<DbSpecification> getDbSpecifications()
If the system under test (SUT) uses a SQL database, we need to have a configured DbSpecification to access/reset it.
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 set such field with DbSpecification.connection.
This connection object will be used by EvoMaster to analyze the state of
the database to create better test cases.
To handle db in the context of testing, there might be a need to initialize
data into database with a sql script. such info could be specified with
DbSpecification.dbType
With EvoMaster, we also support a smart DB cleaner by removing all data in tables
which has been accessed after each test. In order to achieve this, we requires user
to set a set of info such as database type with DbSpecification.dbType,
schema name with DbSpecification.schemaNames (TODO might remove later).
In addition, we also provide an option (default is true) to configure
if such cleaner is preferred with DbSpecification.employSmartDbClean.
null if the SUT does not use any SQL databasedefault Object getMongoConnection()
default void registerOrExecuteInitSqlCommandsIfNeeded()
register or execute specified SQL script for initalizing data in database
default void resetDatabase(List<String> tablesToClean)
reset database if the smart db cleaning is employed
default boolean resetCustomizedMethodForMockObject()
a method to reset mocked external services with customized method
default boolean mockRPCExternalServicesWithCustomizedHandling(String externalServiceDtos, boolean enabled)
a method to employ customized mocking of RPC based external services
externalServiceDtos - contains info about how to setup responses with json format, note that the json should
be able to be converted to a list of MockRPCExternalServiceDtoenabled - reflect to enable (set it true) or disable (set it false) the specified external service dtos.
Note that null [externalServiceDtos] with false [enabled] means that all existing external service setup should be disabled.default boolean mockDatabasesWithCustomizedHandling(String mockDatabaseObjectDtos, boolean enabled)
a method to employ customized mocking for database
mockDatabaseObjectDtos - contains info about how to set up mock object for databases with json format, note that the json should
be able to be converted to a list of MockDatabaseDtoenabled - reflect to enable (set it true) or disable (set it false) the specified mock object
Note that null [mockDatabaseObjectDtos] with false [enabled] means that all existing mock objects for databases should be disabled.Copyright © 2016–2023. All rights reserved.