New with circleci. How do I configure the circle.yml to run my .cls test files?
hi there, not sure what .cls files are, or what testing framework you are using.
The circle.yml file basically runs commands as if it were on the command line.
In the test:
part of the yml file probably, you will want to put in the same command that you would normally use to run the test.
eg, if you have - echo "Foo Bar"
in your circle.yml, you will see Foo Bar
get printed out when you run a build in circleci.
They way we do it is like so
test:
override:
-cd path/to/my/shell/script && ./test-runner.sh:
parallel: true
The test:
part tells circleci when to run the command.
the override:
part tells ci that you want to run this command, overriding the default inferred commands.
then I cd into the dir that has my shell script, and I run the script.
That script basically runs the tests the same way they would be run from the command line in my local dev environment.
The parallel: true
part means that this command will run for every container I have, as opposed to just once.
I hope that helps.
Thanks. My test cases are Apex unit tests. How do I run them in circleci and capture the results?
Hey
Weirdly we were just setting this up ourselves. You need to use the ant migration tool (see here for download instructions)
You can then set your circle.yml file up something like:
test:
override:
- ant deployCodeRunLocalTests
I am working on how we get the output results.
Paul
Super, please post here when you got the output working.
Thanks so much!
I get output when I do this in my build.xml
<target name="deployCode">
<sf:deploy username="${env.USERNAME}" password="${env.PASSWORD}" serverurl="${env.SERVERURL}" maxPoll="100" deployRoot="src" **testLevel="RunLocalTests">**
</sf:deploy>
</target>
<!-- End DealerTeam Build Targets -->
Thanks for the note, we have the output in a text format but were more trying to think of how to get artifacts etc. At the moment we are just doing:
test:
override:
- ant deployCodeRunLocalTests | tee myFile.txt
Which output the results for us in a file for use later on.
That is exactly what I am trying to accomplish.
I launch this script from circle.yml to get the failed test cases:
#!/bin/sh
echo “Deploying and running the unit tests”
ant deployCode | tee testResults
if grep -q “fail” testResults
then
echo “Failed test cases:”
cat ./testResults | grep fail | awk ‘{print $2, $3}’
exit 1
else
echo “Test Cases passed”
fi
exit 0
But is there a better way to view those results in circleci…as one would in the MavensMate-App for example