Tests fail with 'mvn test' on grails project converted from 2.2.4 to 2.4.3 - unit-testing

I have successfully converted two projects from grails 2.2.4 to 2.4.3. I can run the tests, and run-app both from the grails command line, and within ggts.
Then, I converted it to a maven project, by using create-pom to get an initial pom.xml file. After getting the dependencies right, I can again run the tests and the app from the command line and ggts. But I am getting errors on my unit tests (not spock tests) using 'mvn test'.
The errors look like this:
java.lang.NullPointerException
at grails.test.runtime.GrailsApplicationTestPlugin.createParentContext(GrailsApplicationTestPlugin.groovy:143)
at grails.test.runtime.GrailsApplicationTestPlugin.initGrailsApplication(GrailsApplicationTestPlugin.groovy:96)
at grails.test.runtime.GrailsApplicationTestPlugin.onTestEvent(GrailsApplicationTestPlugin.groovy:327)
at grails.test.runtime.TestRuntime.deliverEvent(TestRuntime.groovy:295)
It feels like some kind of setup , or dependency issue.

Related

phpunit tests returning no assertions and all errors

I am new to unit testing (and would really like to learn). I tried pulling down this repository (https://github.com/serbanghita/Mobile-Detect) and have been trying to run their unit tests they already have set up. I have it to the point where phpunit is running but when I run
phpunit tests
from the root directory I get:
Tests: 1411, Assertions: 0, Errors: 1411
I have tried running
phpunit --configuration tests/phpunit.xml
but then I get the error:
Class "JohnKary\PHPUnit\Listener\SpeedTrapListener" does not exist
They have something in their documentation about running:
php phpunit.phar -c tests/phpunit.xml
but I get the error
Could not open input file: phpunit.phar
which is because of the way I have phpunit set up I'm sure...
Any suggestions on how to further trouble shoot this?
It appears you have configured https://github.com/johnkary/phpunit-speedtrap to be used as a test listener in your phpunit.xml but have not (properly) installed this extension.
And if your PHP cannot find phpunit.phar then you are either not pointing it to the correct path or you have not downloaded / installed the PHPUnit PHAR, maybe because you chose to install PHPUnit via Composer. In that case the correct path would be vendor/bin/phpunit, of course.

Error testing Polymer Dart components

I'm having trouble getting any of my Polymer Dart tests to run due to the following error that appears after I run pub run test --pub-serve=8081 -p chrome
00:18 +1 -2: compiling test\markdone_test.dart
Failed to load "test\markdone_test.dart": Reflecting on type 'TodoInput' without capability
dart:_internal wrapException
TodoInput is one of the Polymer Dart components for this project, but I've gotten the same error on other projects I have tried testing.
I have followed the documentation on the pub package for dart-lang/test:
Added listorder_test.dart and listorder_test.html with x-dart-test referencing my dart file
Added an entrypoint under the polymer transformer for test/listorder_test.html
Added the test/pub_serve transformer with $include: test/**_test{.*,}.dart
Am I missing some setup step or annotation/metadata? I've been over the docs for testing and they really only have the one mention of testing Polymer components without much else.

TeamCity does not catch failing tests in minitest

I have TeamCity up and running in a mac environment. A trigger is also setup to to run a rake task containing a number of test cases on every git commit. The rake command successfully pulls the code and runs the test cases. The passing test cases are shown correctly in the TeamCity interface, however, the failing test cases do not show up and the build is marked as successful. When I look at the error Build Log, failing tests are shown as errors. The question is why TeamCity is interpreting failing tests as errors and not as actual failing tests?
The assertions are as simple as the following (obvious failure):
test 'simple_test' do
a = 14
ssert_equal 341, a
ends
PS: the check box to fail the build upon at least one test fail is turned on in Failure Conditions(i.e. at least one test failed)
Ruby version = 2.2.2,
Rails version = 4.2.1,
TeamCity version = 9.1.1,
Testing framework = minitest,
Here is the build log output
Teamcity is not picking up failed tests because mini-test reporter is not up and running. To fix this, following gems must be present in the Gemfile:
gem "minitest", :group => :test
gem 'minitest-reporters', :group => :test
Also minitest reporter must be called. The best place to call it is test_helper.rb
require 'minitest/reporters'
MiniTest::Reporters.use!

launch one jasmine test with grunt and karma?

I have a big web project with many javascript Jasmine unit tests.
In that web project, i use grunt, karma and jasmine.
Is there any way to launch only one test javascript with grunt with a command line ?
Launching all tests is long, so how to do that without modify my gruntfile.js or my karma-unit.conf.js ??
I tried the following command, but it is more a hack than a real solution :
karma run -- --grep=filteredtestexpr
I am not sure of the best way to specify which test to run from the command line. But it seems like your problem can be solved with the following two pointers:
Change the name of a test from it to iit and karma will run only that test (actually all iit tests).
Change describe to ddescribe to run the entire describe block.
Also, use xit and xdescribe to explicitly exclude tests.

maven test | NoClassDefFoundException DirectFileOutputcommitter

I am using maven surefire plugin for unit testing. One of the unit tests crash because of the following exception:
java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/lib/output/DirectFileOutputCommitter
Googling on this tells me that this class def is found in amazon-s3.jar, which resides in the hadoop/lib folder of my hadoop distribution. How do I get around this exception in unit tests?