I am using POSTGRES SQL as DB for my springboot application .Sonarqube integration test cases fail as SonarQube is unable to connect to DB.How can i disable my integration test cases using gradlew command during Jenkins build ?
Below is link where i have shown my code in detail SonarQube does not calculate code coverage
You would likely have to have some kind of naming convention for the tests you wish to exclude. Then, you can readily exclude them using something like the following:
In your build.gradle file, add:
test {
if (project.hasProperty('excludeTests')) {
exclude project.property('excludeTests')
}
}
From the command line:
gradle test -PexcludeTests=**/Integration*
Related
I am developing a pipeline for hybris.
I have doubts in the execution of the tests.
I'm following this tutorial:
https://clutcher.github.io/post/hybris/improve_hybris_test_run/
However, I have several extensions in customizing hybris.
Do I have to configure the buildcallbacks.xml file for each extension?
Is there any way to run the ant ci for all extensions?
For a first version I would use the following ant tasks:
integrationtests
performancetests
manualtests
bugprooftests
localizationtest
typecodetest
alltests
allwebtests
Make sure to mark your tests with the #IntegrationTest or #UnitTest annotation so that the ant task will find them.
You can filter the tests by:
extensions using the parameter -Dtestclasses.extensions=myextension
packages using the parameter -Dtestclasses.packages=my.package
excluded packages using the parameter -Dtestclasses.packages.excluded
For more information consider:
https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2005/en-US/f7f454a4f5254944a366db9bdf129be6.html
I use the yml configuration files pattern application-{default,dev,production}.yml.
To define which configuration application will use, I fix the environment SPRING_PROFILES_ACTIVE=dev so when the spring app run, it choose the correct configuration.
I have now theses two issues:
The ./gradlew build command also run the test command, test need to have the correct configuration as the application does when it start.
My jenkins does not have access to the database and the units tests keep failing.
Which make make ask:
Does the build command tries all the datasource in order ? Is there a way to specify the spring boot active profile ?
Is there another different approach for deploying spring-boots app in production from jenkins ?
Does anyone has a workaround except
./gradlew -x test build
This is not what I want.
Neither adding #ActiveProfile("dev") to my tests because this require source code modification.
Simply Create multiple property files.For Example:
application.properties
application-test.properties
application-production.properties
Provide different properties based on profile and
Below you can specify
which profile to load in you gradle.build file
def profile = "test"
bootRun {
args = ["--spring.profiles.active="+profile]
}
Put below code in the end of gradle file
Following is the directory structure for my integration tests
/src/it/first-test
-->my-test
-->build.log
-->inoker.properties
-->pom.xml
-->verify.groovy
When I try to run a single integration tests as described https://maven.apache.org/plugins/maven-invoker-plugin/usage.html. It gives a message that ' No projects were selected for execution' Here is the command I used to invoke the project
/src/main> mvn invoker:run -Dinvoker.test=first-test/my-test*
How should I make sure the test is run?
It looks like you misunderstood the docs how to structure your integration tests. The first integration test should be located /src/it/first-test the second integration test should be located /src/it/second-test which means your folder my-test should be removed...Furthermore you should start the integration test from your project root and not by mvn invoker:run you should use mvn verify -Dinvoker.test=first-test instead...
It looks like you are executing it from src/main. Try it again from the root of the project (where the pom.xml is located).
I use QF test tool (http://www.qfs.de/en/qftest/) to run my integrated UI based tests . Is there any tool which can get code coverage of qft test suites ?
Note : I use Sonar (jacoco plugin) to get code coverage for Junit tests .
I googled a lot and couldn't find any relevant documentation for this . So any links to documentation or example would be helpfull
oYes, this is possible. I'm using QF-Test with Jenkins CI, Sonar and JaCoCo.
To keep it short, in QF-Test go to the step which invokes the SUT and add the -javaagent: parameter to the program
e.g.:
-javaagent:/path/to/mvnlib/org.jacoco.agent-0.6.4.201312101107-runtime.jar=destfile=/usr/share/tomcat6/.jenkins/jobs/Integration_Build/workspace/your.program.test/jacoco/jacoco-qf.exec,includes=your.packages.*,output=file
Configure Jenkins (with Jacoco Plugin) to look for jacoco-qf.exec file.
PS: If you use regular Junit Tests you should combine both the coverage of QF-Test and Junit by this Ant script:
<jacoco:merge destfile="${jacoco.file}">
<fileset dir="${jacoco.report.dir}" includes="*.exec"/>
</jacoco:merge>
I was wondering whether it's possible to obtain information about test execution order somehow.
I have a project in Maven and all the tests are passing. After I migrated the project to Gradle, one of the tests started failing. The test itself is working: when I execute gradle test -Dtest.single=..., it passes. However, when I run the tests for the whole project, the test fails.
It's possible that some tests that run before the failing test do not release resources correctly and therefore the test fails. But I need to somehow find out which tests are causing this problem.
Tell Gradle to log more events about test processing. There is a documentation how to do that http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.logging.TestLoggingContainer.html
The beforeTest method can be used to output details about each test before it is run, based on a TestDescriptor for each test:
test {
beforeTest { testDescriptor ->
println "${testDescriptor.className} > ${testDescriptor.name} STARTED"
}
}