Unable to get code coverage for a scala application using Scoverage - scala

I am unable to measure code coverage for my scala application using the tests written in Python. Steps followed to generate the report,
Compile the application
activator -Dsbt.override.build.repos=true -Dsbt.repository.config=./repositories -Dsbt.log.noformat=true clean coverage dist
Run the application on port 9002
cd target/universal
unzip sample-app-1.0.zip
cd sample-app-1.0
bin/sample-app -Dhttp.port=9002
Run python tests against this application
cd /home/python-tests
python ./tests/sample_tests/pkg1/
lsof -t -i:9002 (Kill the application)
activator -Dsbt.override.build.repos=true - Dsbt.repository.config=./repositories -Dsbt.log.noformat=true coverageReport
Can someone please help me understand if the setup is correct?

Related

How can we use Junit test without eclipse

I have wrote a piece of code in Junit. I need to run it without eclipse. Any suggestions how can I do that ?
Since Eclipse 2018-09 in Java Application and JUnit launch configurations there is a button Show Command Line for that.
See also: video that shows this feature in action
Yes, you have an option to run your test cases in command line,
Example:
As you are running the mvn clean install for building your application,
In the same way, you can also run your test cases as well by using the command.
1. Command to compile your test class >> **javac -cp junit-4.12.jar;. UserDAOTest.java ProductDAOTest.java** --> general command is >> **javac -cp <junit-jar-file>;. TestClass1.java TestClass2.java**
2. Run the test cases >> ** java -cp <junit-jar>;<hamcrest-jar>;. org.junit.runner.JUnitCore TestClass1 TestClass2 **
3. Running the unit test cases by Maven Command Line >> mvn test >> mvn clean test >> mvn clean compile test

SBT - why sbt giving compilation errors while running?

I am trying to merge two modules into single module. Both are successfully running modules. I merge two modules. And trying to run the test cases.
i am compiling source and testcases by using sbt commands:
sbt
clean
compile
project module-read
test:compile
it:test
Till test:compile everything working fine but after it:test, it showing lot of compilation issues.
Could I know best way of compiling?
The test:compile task will only compile tests within the src/test/scala folder as per the default sbt test configuration.
In order to compile your integration tests (in src/it/scala) you will have to run it:compile .
See http://www.scala-sbt.org/0.13.5/docs/Detailed-Topics/Testing.html#integration-tests for more info.

Scala package ith SBT - Can't find " .../immutalbe/Map"

I've created a simple app that generates PageView for later Spark tasks.
I've only one scala file taht use a simple MAP
When created a package with SBT I run my class with command:
java -cp .\target\scala-2.10\pageviewstream_2.10-1.0.0.jar "clickstream.PageViewGenerator"
but I receive this error:
Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/immutable/Map
What I am doing wrong?
Many thanks in advance
Roberto
To run it correctly you need to add Scala runtime library into your class path:
java -cp $SCALA_HOME/lib/scala-library.jar;.\target\scala-2.10\pageviewstream_2.10-1.0.0.jar "clickstream.PageViewGenerator"
But .. you can run your application also as:
scala -classpath .\target\scala-2.10\pageviewstream_2.10-1.0.0.jar "clickstream.PageViewGenerator"
when you have scala already in PATH
or use directly sbt as:
sbt "runMain clickstream.PageViewGenerator"
when clickstream.PageViewGenerator is you only application it is enough to run:
sbt run
or when you are in sbt interactive mode just type:
> runMain clickstream.PageViewGenerator
or when it is only application in your project it is enough to run:
> run

Configure repo for SBT launcher in Travis build

Where can I override the repo URL that SBT uses to fetch its launcher when the SBT instance is provided by Travis-CI?
http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.8/sbt-launch.jar is currently giving 404s and, as a result, the builds are failing on Travis with:
$ sbt clean dependencyUpdates coverage test coverageReport
Detected sbt version 0.13.8
Downloading sbt launcher for 0.13.8:
From http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.8/sbt-launch.jar
To /home/travis/.sbt/launchers/0.13.8/sbt-launch.jar
Download failed. Obtain the jar manually and place it at /home/travis/.sbt/launchers/0.13.8/sbt-launch.jar
I ran into the same problem today, and logged an issue for travis-ci: https://github.com/travis-ci/travis-ci/issues/4527
As a workaround, you can download the sbt-launcher.jar by adding a before_script section to your .travis.yml
before_script:
- mkdir -p $HOME/.sbt/launchers/0.13.8/
- curl -L -o $HOME/.sbt/launchers/0.13.8/sbt-launch.jar http://dl.bintray.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.8/sbt-launch.jar
We just deployed the fix to production. SBT builds should be working now.
Sorry for the inconvenience.
https://github.com/travis-ci/travis-ci/issues/4527#issuecomment-124123880

Is there a log file for tests that are run during maven build life cycle?

When I run mvn clean install, it runs my tests and 2 of them fail. When I run them on their own as junit tests, they pass. It only tells me that they failed during the mvn clean install and not why they failed. I'm wondering if there's a log for the tests run during the build lifecycle that I'm not aware of. Or do I need to set up my own logging system for this?
You can have a look at the test report:
target/surfire-reports/index.html