Running the Unit test cases in solr using ant - unit-testing

I am trying to run my test cases in solr using ant. Below is the ant command I am using:
ant test –Dtestcase=<test case name> test -Dtests.leaveTemporary=true
Now I have my own customized solrconfig & schema, so running above command builds the project again & overrites my customized solrconfig & schema.
Kindly help me with this.

You can use the method:
initCore(String config, String schema, String solrHome) of class SolrTestCaseJ4.java in your TestCase and pass the path of your customized schema and config as your solrHome(typical format: solr\collection1\conf).

Related

Generate xUnit test results in .json format

Currently, I'm running a set of xUnit test using the following command:
dotnet test --filter TestType=$testType --logger trx
Is there a way to generate results in json format? Something like --logger json?
Thank you.

How to run quarkus tests using certain profile defined in application.properties

Say I have the following in application.properties:
quarkus.datasource.url=${db_url:jdbc:postgresql://localhost:5432/ekycapi}
%dockerrun.quarkus.datasource.url=${db_url:jdbc:postgresql://postgres:5432/anotherdb}
When running in dev mode, I run as "mvn quarkus:dev -Dquarkus.profile=dockerrun"
But what if I want to use the same profile while running the tests? What is the correct syntax for it? Something like "mvn test -Dquarkus.profile=dockerrun"?
Use quarkus.test.profile to set the desired test profile. See more config options on the all-config page

Jenkins tests reports analyzer integration with catch

I've recently started working with Jenkins to automatically build my c++ project and run my tests (I'm using catch.cpp).
I wanted some sort of a table of test run time and status and that led me to the "Test Results Analyzer" Plugin for Jenkins.
I have my builds run like this:
And you can see they actually run in the console output:
finally, my test results analyzer plugin shows nothing:
It looks like the plugin does not recognize that these are my tests. Which is reasonable since I've only told jenkins to execute these commands and i don't think it's smart enough to understand these are the tests to report. But i could not find how to tell "Test Reports Analyzer" what are the tests it needs to report.
My question is how do i get a table of tests like in the Plugins webpage:
Tests Reports Analyzer
Solution:
Jenkins needs a Junit format xml file of the test results.
specifically, in Catch.cpp this is achieved by the "-r junit" command line option.
after this i needed to configure jenkins to "Publish JUnit test result report" post-build action and git it a path to the output xml file i create with my "make test" command.
Solution provided by OP:
Jenkins needs a Junit format xml file of the test results.
specifically, in Catch.cpp this is achieved by the "-r junit" command line option.
after this i needed to configure jenkins to "Publish JUnit test result report" post-build action and git it a path to the output xml file i create with my "make test" command.

How to deploy a ember-cli app with a grunt task?

When I want to deploy my app to my enviroment I have to create a single file in a specific, containing the hole app (most of it BASE64 encoded) and import that file into a proprietary application.
I've created a grunt task that can easily generate that file form a folder. So I'm looking for a way to just type something into the console and then it should execute ember build and my script.
The simplest way to do this is just to create a brand new Gruntfile.js nearby the existing Brocfile.js and a batch file to run first grunt and then ember build.
A better way would be if I could call ember build from my gruntfile. Is there a way to do this?
Or, even better, is there a way to inject a grunt into the ember build? That would be awesome!
To be clear, broccoli is not the right tool for that! Its not a build step, but a deployment step! So I want to use the task runner, not the build tool.
Thanks!
You could potentially use grunt-exec to execute ember build, as part of a chain of grunt build tasks.
It allows you to execute arbitrary shell commands.
Something like the following might work:
grunt.initConfig({
exec: {
ember_build: {
command: 'ember build'
}
}
});
and then execute with grunt exec:ember_build or as part of a larger task. (Note that I haven't tried this, but it should work!)
This might be slight overkill, you could just chain your console commands:
ember build && grunt

Gradle jacoco code coverage - Then publish/show in Jenkins

I'm trying to setup code coverage for a Java application project.
Project name : NewApp
Project structure:
src/java/** (source code)
src/java-test (unit tests - Jnuit)
test/it-test (integration test)
test/at-tests (acceptance tests)
tomcat/* (contain tomcat start/stop scripts)
xx/.. etc folders which are required for a usual application.
Gradle version : 1.6
Environment : Linux
I have a running gradle build script that fetches application (NewApp) dependencies (i.e. service jars used by the app for build process) from a build artifact repository (artifactory/maven for ex), and builds the app.
Now at this point, I wanted to get code coverage using JaCoCo plugin for my NewApp application project.
I followed the documentation per Gradle/Jacoco but it doesn't seems to create any reports/... folder for jacoco etc where I can find what Jacoco coverage report did.
My questions:
1. For getting code coverage using Unit tests (Junit), I assume all I have to do is the following and it will NOT require me to start/stop the tomcat before running unit test (test task i.e. "gradle test") to get code coverage for/via using unit tests. Please advise/correct. The code (just for Gradle jacoco unit test part) - I'm using is:
apply plugin: 'jacoco'
test {
include 'src/java-test/**'
}
jacocoTestReport {
group = "reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.enabled true
html.enabled true
csv.enabled false
}
//classDirectories = fileTree(dir: 'build/classes/main', include: 'com/thc/**')
//sourceDirectories = fileTree(dir: 'scr/java', include: 'com/thc/**')
additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
}
and for Integration tests:
task integrationTest(type: Test) {
include 'test/java/**'
}
As jacocoTestReport is depends upon test task(s), thus they will be called first and then finally jacocoTestReport will report what it found for the code coverage.
For getting code coverage for integration tests, I assume I must start tomcat first (i.e. before running / calling test target for integration tests), then call "gradle integrationTest" or "gradle test" task and then stop tomcat -- to get the code coverage report. From other blog posts I also found that one should setup JAVA_OPTS variable to assign jacoco agent before tomcat starts.
for ex: setting JAVA_OPTS variable like:
export JACOCO="-Xms256m -Xmx512m -XX:MaxPermSize=1024m -javaagent:/production/jenkinsAKS/jobs/NewApp/workspace/jacoco-0.6.3.201306030806/lib/jacocoagent.jar=destfile=/production/jenkinsAKS/jobs/NewApp/workspace/jacoco/jacoco.exec,append=true,includes=*"
export JAVA_OPTS="$JAVA_OPTS $JACOCO"
Being new to Gradle/groovy - I'm not sure what code should I write within build.gradle (build script) to get the above Integration/Unit tests working if it involves start/stop of tomcat. If someone can provide a sample script to do that, I'll try.
I'm not getting any code coverage right now, when I publish Jacoco code coverage in Jenkins (using Jenkins post build action for publishing Jacoco reports). Jenkins build dashboard shows 0% for code coverage (i.e. bars showing all red color, no green for actual code coverage).
Need your advice to get some traction on this.
Question : I assume that your unit tests doesn't depend on tomcat. In this case, you're right, you must not start tomcat upfront.
To create the coverage report you need to execute
gradle jacocoTestReport
without jacocoTestReport gradle won't trigger jacoco to generate the reports.
One additional thing, regarding to your snippet. I assume that you have changed the the default main sourceset to source/java. in this case you don't have to set the additionalSourceDirs.
Integration tests : Yes, you need to start tomcat first, or at least you have to ensure that tomcat is running. You should have a look into Gradle 1.7. It has a new task ordering rule called finalizedBy
With this you could do something like
task integrationtests(type: Test) {
dependsOn startTomcat
finalizedBy stopTomcat
}
where start/stopTomcat are custom tasks.If you have to stay on Gradle 1.6 you have to build a dependsOn chain:
stopTomcat -dependsOn-> integrationtests -dependsOn-> startTomcat
I assume that the blog article is right, I don't have any experience with that.
Starting/Stoping Tomcat : You could do it in a way like this
task startTomcat() << {
def tomcatStartScript = "${project.rootDir}/tomcat/startScript"
tomcatStartScript.execute()
}
The stop script can be written in a similiar way. (Some in from Groovy doc : Executing)
Jenkins & Jacoco : Should be fixed when executing jacocoTestReport
Got it working.
Gradle 1.7
- download the .zip which contains the binaries/src and documentation.
- Go to folder: if you unzip the above .zip at C:\gradle-1.7
C:\gradle-1.7\samples\testing\jacoco\quickstart
Run:
gradle build jacocoTestReport
You’ll see a new folder “build” after the build.
– folder jacoco gets created with classdumps and .exec if only build task is called.
– folder jacoco and jacocoHtml gets created – if both build jacocoTestReport is called
have fun.
I also saw that it’s better to include:
the following section in build.gradle
/////
tasks.withType(Compile) {
options.debug = true
options.compilerArgs = ["-g"]
}
////