Unit testing Quartz plugin for Grails - unit-testing

I have some trouble writing the most basic unit test for a job. My problem can be recreated by creating a new job by running grails create-job my in the console.
This will create two files
MyJob.goovy (under the default package myApp - resides in test\unit\myApp)
MyJobSpec.groovy (under the default package myApp - resides in grails-app\jobs\myApp)
Now if i try to use the job MyJob in the test, as example
import myApp.MyJob //This is not resolved
#TestMixin(GrailsUnitTestMixin)
class MyJobSpec extends Specification {
def myJob
I get the compiler error Groovy:unable to resolve class MyJob. Everything so far was automatically created by the plugin. What is going on here? Is there something i did wrong / how do i get this to work?
Using grails 2.3.11.

I don't know which IDE are you using or if you are running everything on a terminal, but I had similar problems with Eclipse and what you need to do is to add grails-app/jobs to the classpath as a source folder.

Related

AndroidStudio 3.2 test configuration does not work

After migrating to AS 3.2 android JUnit test run configuration does not work, all types "All in directory",
"All in package" etc.
I mean it does work, but always claims that:
0 test classes found in package '<default package>'
Process finished with exit code 254
Empty test suite.
using ./gradlew test triggers every test
and every single test can be run by AS using that green play button inside editor (for class or single method)
but not for package, module etc.
How to fix that ?
many thanks
Wojtek
Declare your test classes as public
Fixed in Android Studio 3.2.1
So just update AS to newest version and the problem disappears

Ember CLI: Attempting to register an unknown factory: `controller:object`

My ember-cli version is 0.2.3. I am getting the following error when I try to run tests.
TypeError: Attempting to register an unknown factory: `controller:object`
at Object.Registry.register (http://localhost:7357/assets/vendor.js:12208:15)
at Object.container.(anonymous function) [as register] (http://localhost:7357/assets/test-support.js:1905:44)
at Object.isolatedContainer [as default] (http://localhost:7357/assets/test-support.js:1946:15)
at exports.default.klassy.Klass.extend._setupIsolatedContainer (http://localhost:7357/assets/test-support.js:2406:52)
at exports.default.klassy.Klass.extend.setupContainer (http://localhost:7357/assets/test-support.js:2312:14)
at nextStep (http://localhost:7357/assets/test-support.js:2300:53)
at exports.default.klassy.Klass.extend.invokeSteps (http://localhost:7357/assets/test-support.js:2305:14)
at exports.default.klassy.Klass.extend.setup (http://localhost:7357/assets/test-support.js:2275:19)
at Object.qunit.module.setup (http://localhost:7357/assets/test-support.js:1814:16)
at runHook (http://localhost:7357/assets/test-support.js:3534:20)
Any idea on what might be causing this? Looking like a ember-cli internal issue.
I am actually using v2.3.0-beta.2 of Ember CLI. When you fire it up, it displays v0.2.3 on terminal for some reason.
Ember version is 2.0.
I have a unit test for a model that triggers this. The test is using moduleFor rather than moduleForModel as my app doesn't use Ember Data.
I am actually using v2.3.0-beta.2 of Ember CLI. When you fire it up, it displays v0.2.3 on terminal for some reason.
This happens because your globally installed Ember CLI is different from the version specified in the project's package.json.
What Ember CLI does when you run a command if check if it's inside an Ember project. It does this by checking for a package.json file in the current, or parent, directory. If it finds it, it will then delegate the command to the Ember CLI that your project depends on.
This is done to make sure that the commands (generate, build, etc) called are the right version and won't break your application.

Where is HibernateTestMixin located in Grails 3?

I am trying to upgrade a Grails 2.5.1 application to Grails 3.0.5. When I try to run the tests I get a compiler error
/Users/xxx/dev/xxx/src/test/groovy/y/xxx/z/PricingSpec.groovy: 5: unable to resolve class grails.test.mixin.hibernate.HibernateTestMixin
# line 5, column 1.
import grails.test.mixin.hibernate.HibernateTestMixin
It seems that grails-plugin-testing does not include that Mixin. Can anyone tell me what dependency I am missing?
EDIT Same goes for grails.test.mixin.gorm.Domain
Have a look at HibernateTestMixin Basics.
You would need this dependency in build.gradle:
dependencies {
testCompile 'org.grails:grails-datastore-test-support:4.0.4.RELEASE'
}
You might not have noticed it but these mixin were already had been moved to grails-data-mapping in Grails 2.4.* apps
If you look closely in BuildConfig.groovy of a newly created Grails 2.4.* or 2.5.*, one would see the same dependency.

How to unit test Dart in Phpstorm

I installed the dart plugin, set the SDK home path to the dart-sdk folder, configured the scope and checked the 'Dart SDK enabled' option in Phpstorm 6.0.3. Next, I created a dart file in a 'test' directory with the following code (obviously I added the dependency unittest in my pubspec.yaml and ran pub get):
library mytests;
import 'package:unittest/unittest.dart';
main(){
test('my test', (){
expect(1+1, equals(2));
});
}
When I run this unit test however (by right clicking inside the file and selecting 'Run Test: my test', an error is outputted in the unit testing window stating the following:
C:/dart/dart-sdk/bin/dart.exe --ignore-unrecognized-flags --package-root=C:/Users/myname/dart/pokerdart/test/packages/ C:\Users\myname\AppData\Local\Temp\jetbrains_unit_config.dart
Testing started at 18:55 ...
'file:///C:/Users/myname/AppData/Local/Temp/jetbrains_unit_config.dart': error: line 1 pos 1: unresolved implicit call to super constructor 'Configuration()'
import 'package:unittest/unittest.dart';
^
When I run the test using powershell it just works... Am I missing something/doing something wrong?
Any help is greatly appreciated!
WEB-9636 is fixed in version 7. Please try upgrading to PHPStorm 7.1.3. Or, even better, try PHPStorm 8 EAP (http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program) - Dart support has been improved there

Running unit tests in Pydev

I am trying to run unit tests in Pydev using IronPython.
When I try to run a test with Ctrl+F9 the following error message shows up in the Eclipse console window:
AttributeError: 'module' object has no attribute '_getframe'
I figured out that I have to invoke the IronPython interpreter with the '-X:Frames' argument.
Setting up the arguments in the 'Arguments' tab under 'Run->Run Configurations...' doesn't work. They seem to disappear everytime I run (Ctrl+F9) and choose another test.
Clicking 'Run->Run As->Iron Python unit-test' shows up more and more options to choose from.
Is Eclipse/Pydev creating new run configurations everytime I run a different set of tests? How can I permanently pass the '-X:Frames' argument, so my tests will run under IronPython?
(In Python the tests run without any problem.)
This shouldn't really be needed... I've just fixed the PyDev unittest runner so that it works properly (just pushed a new nightly build with that fix included -- if you're in Aptana Studio 3, a nightly is still not available, but you can patch your own version by applying the changes from the commit locally, as they're all changes in Python code: https://github.com/aptana/Pydev/commit/d5d262dbcd0c126ec0ec37e116ff79575c5dd6d8)