How to configure active profile in spring boot

I wrote a end to end test case and want to execute it as a active profile. Could someone suggest the steps. As of now I am getting error as

2: Task failed with an exception.


  • What went wrong:

Cannot invoke method replaceAll() on null object

In a Gradle Test task running against a Spring Boot app, it is common to specify a Spring profile as a System property in the task declaration:

systemProperty 'spring.profiles.active', 'e2e'

There is not enough information here to determine why you may have a null pointer issue in your build script though.

Thank you. here is my end-to-end-tests.gradle

sourceSets {
endToEndTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
//srcDir file(‘src/endToEndTest/java’)
srcDir file(’/abcd-tes-layer/src/endToEndTest/java’)
}
resources.srcDir file(‘src/endToEndTest/resources’)
}
}

configurations {
endToEndTestCompile.extendsFrom testCompile
endToEndTestRuntime.extendsFrom testRuntime
}

task endToEndTest(type: Test) {
testClassesDir = sourceSets.endToEndTest.output.classesDirs
classpath = sourceSets.endToEndTest.runtimeClasspath

reports.html.destination = file("${reporting.baseDir}/${name}")

}

and error that I get now is

  • What went wrong:

A problem occurred evaluating script.

Could not set unknown property ‘testClassesDir’ for task ‘:endToEndTest’ of type org.gradle.api.tasks.testing.Test.

Please suggest.

The Test task property testClassesDir was deprecated and then removed in more recent versions of Gradle. You should change testClassesDir to testClassesDirs.

task endToEndTest(type: Test) {
    testClassesDir = sourceSets.endToEndTest.output.classesDirs // this line needs to change
    classpath = sourceSets.endToEndTest.runtimeClasspath
    reports.html.destination = file("${reporting.baseDir}/${name}")
}