In automation tests, I have a problem with connecting to the database of the testing environment in order to clear the database before and after tests.
But there is a script in the backend repo that clears the database and which I could use. I thought that the easiest way to trigger this script would be by calling a swagger API endpoint provided by the backend.
But in order to keep the production environment safe, this endpoint should be available only in the testing environment.
But how to do this properly?
CodePudding user response:
Just use @Profile({"!prod && swagger"})
on configuration class.
@Configuration
@Profile({"!prod && swagger"})
public class SwaggerConfig {
..
}