Code coverage of Vue files in Rails project - ruby-on-rails

In existing Rails+Vue.js (with webpacker) project we have plenty of feature tests (Capybara tests).
At the moment we can only see code coverage of ruby code.
Is there a way to setup code coverage for Vue/Javascript code without writing JS based tests from scratch?

Related

Code coverage of Polymer Application with WCT

I have the sapplication developed in Polymer and unit testing with WCT. I want to generate the code coverage report for that.
I tried with the istanbul(web-component-tester-istanbul), but it is not supporting it, I am using Polymer Version 1.2.
And I tried with Karma + Grunt, but I am not able to genrate the code coverage report.
Can anybody tell me how we can generate code coverage with Karma? I search on google but not able to find WCT with Karma.
You can use the modified version for now till the original Istanbul is fixed to work with Polymer. wct-Istanbub

How can I unit test a gluon mobile application?

I have created a "Gluon Mobile - Multi View Project with FXML" using IntelliJ. Now I would like to write junit tests for code residing in the main directory, additionally I would like to write unit tests for platform specific code residing in the android, desktop and ios folders.
I managed to write unit tests for the main code by adding a src/test/java folder. Those tests get automatically executed when building the project.
But how can I add platform specific unit tests and integration tests? What do I have to add to build.gradle to make the jfxmobile-plugin know and execute those tests?
Any help is very much appreciated.

How can I define a third Java source folder for Maven which gets compiled into a third JAR?

By default, Maven standard directory layout has two Java source folders:
src/main/java
src/test/java
For my purposes, I need a third one src/junit/java which should be packaged into a JAR with the classifier junit.
If possible, the new source folder should have it's own classpath (compile + everything with scope junit).
My guess is that for this, I will have to modify at least the resource and compile plugins.
Or is there an easier way?
I have a workaround as explained here but for that, I have to put things like Mockito and JUnit on the compile classpath which violates my sense of purity.
For all people who doubt the wisdom of my approach: I have support code that help to write unit tests when you work with code from src/main/java. Since I'm using the same support code in the tests for the project itself, this code needs to be compiled after src/main/java and before src/test/java.
Specifically, my support code needs to import code from src/main/java and the tests need to be able to import the support code.
I've seen a couple of Maven setups, which bundle test code in an own Maven module. You could then create a simple main-module <- support-module <- test-module dependency chain with that. But then main-module would compile fine, if you build it on it's own without test-module. Ofc you could aggreate them together with a reactor-pom and just build the project via this pom.
Edit:
If you have problems with this setup regarding code coverage, you can use the Jacoco Maven plugin to aggregate the test coverage generated by test-module to main-module. See this for further information: http://www.petrikainulainen.net/programming/maven/creating-code-coverage-reports-for-unit-and-integration-tests-with-the-jacoco-maven-plugin/

Finding out rails' test coverage

I've just seen this issue on rails' issue tracker:
https://github.com/rails/rails/issues/2667
And I'd like to find out which parts of the code aren't covered. I couldn't find a coverage tool into the Rakefiles, and searching for it is a bit frustrating, since it returns far more results about test coverage on your rails app than test coverage of the framework itself.
Has anybody set up a code coverage tool? Is there any documentation on how to do it?
Rcov (or SimpleCov for 1.9) is the standard tool for Ruby code coverage. It should be fairly straightforward to get one of these to run the rails tests.

Getting started with Unit Testing on an existing codebase in rails?

G'day guys,
I've started a new role at a company and am working on a rails application that's used internally for particular management applications. At any rate, there are no unit tests associated with this system, and as I am building the system out I've realised there is a serious need to build unit tests so that I can have regression testing as I continue to add to this codebase.
It's a rails 1.2.7 app that I cannot migrate for reasons of compatibility, but I will be beginning to port components over it to 3.0 in the background.
There is currently only the built in tests that rails makes, and I would love some insights into how to get started with building small tests into the system and particularly at what aspects would be good to start?
This system builds a lot of individual config files, so I'm assuming a lot of the test generation would begin with testing those config files for individual aspects/elements and going from there.
I've had a look at cucumber and rspec, but just wanted to find something straightforward and easy to use that I could slowly build upon within the current system and build up a testing base over time.
Any insights, links or others would be really really appreciated.
Cheers!
A lot has changed since Rails 1.2.7, definitely one of the first things would be to right unit tests, but instead of going an all out unit test attack.. Attack the problem component,
Write tests
Upgrade the component
Run Tests ( mostly they'll fail / possibilities of errors )
Make them pass
Refactor ( May be the new features at your disposal )
I usually do the above steps with writing the integration tests, and functional tests and unit tests for the components in the integration tests.
All the best, this ain't going to be a simple task :).

Resources