Grails 4 for DomainClassUnitTest - unit-testing

I am upgrading version of grails 3 to grails 4 and in existing unit tests looking for annotation or plugin which will keep supporting DomainClassUnitTest for mockdomains
Please guide me how can i keep using following code while standing at grails 4 ** mockDomain(record, [testRecord])**

Related

TYPO3 extensions with good tests

I am looking for a TYPO3 extensions with good test examples - unit tests, functional etc. By good I mean - test that covers possibly lot of code and are up to date so I can actually execute them without fixing anything upfront.
Here some examples which I check:
news 7.0.7 - 261 tests, 14 failed
realurl 2.4.0 - fails to execute
femanager 4.2.2 - fails to execute
devlog 3.0.2 - fails to execute
cs_seo 3.0.2 - fails to execute
aoe_ipauth 1.1.0 - fails to execute
Checkout extensions from Oliver Klee, who started 2009 to implement tests in TYPO3 core.
oelib https://extensions.typo3.org/extension/oelib/
realty https://extensions.typo3.org/extension/realty/
seminars https://extensions.typo3.org/extension/seminars/
Also have a look at his example extension 'ext_tea' at Github https://github.com/oliverklee/ext-tea.
A TYPO3 example extension for unit testing and best practices.
Oliver Klee is giving workshops, and has more examples on Github.
Christian Kuhn implemented a view days ago the possibility in TYPO3 9.5 to run Tests using Docker. Documentation is in progress
Run Build/Scripts/runTests.sh -h to see what is possible.

Is dusk is mandatory to write phpunit test cases?how to write phpunit test cases in laravel 5.4?

I am newbie to laravel. I am using laravel 5.4 version, we have requirement of writing phpunit test cases for our application, So I have searched for writing phpunit testcases and also read the documentation in laravel website. I read about the 'dusk' feature for doing the browser tests. So, I have a doubt that is "Is the dusk is mandatory for writing the phpunit test cases in laravel 5.4? I also tried to install the 'dusk' package into our application but it is not getting installed after I run the command "composer require laravel/dusk".
below is the error that I am getting on command prompt:
c:\xampp\htdocs\ourappname>composer require laravel/dusk
using version ^1.1 for laravel/dusk
./composer.json has been updated
Loading composer repositories with package information
Updating dependies (including require-dev)
Package operations: 2 installs, 4 updates, 9 removals
- Removing maatwebsite/excel (2.1.17)
- Removing phpoffice/phpexcel (1.8.1)
- Removing jeremeamia/superclosure (2.3.0)
- Removing symfony/polyfill-php56 (v1.3.0)
- Removing symfony/polyfill-util (v1.3.0)
- Removing guzzlehttp/guzzle (6.2.3)
- Removing guzzlehttp/psr7 (1.4.2)
- Removing psr/http-message (1.0.1)
- Removing guzzlehttp/promises (v1.3.1)
- Updating psy/psysh (v0.8.3 => v0.8.5): Loading from cache
- Updating swiftmailer/swiftmailer (v5.4.7 => v5.4.8): Loading from cache
- Updating sebastian/diff (1.4.1 => 1.4.2): Loading from cache
- Updating laravel/framework (v5.4.21 => v5.4.23): Loading from cache
- Installing facebook/webdriver (1.4.1): Loading from cache
- Installing laravel/dusk (v1.1.0): Loading from cache
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Maatwebsite\Excel\ExcelServiceProvider' not found
Script php artisan optimize handling the post-update-cmd event returned with error code 1
Installation failed, reverting ./composer.json to its original content.
c:\xampp\htdocs\ourappname>
Anyone please tell me how to fix it? and also what is the process for writing the test cases in laravel 5.4? should we use 'dusk'? or any other way to do it? Thanks.
No, Dusk is not required to do unit testing. You can just use the basic tests.
Your error is related to when you installed the Excel package on your application; the Service Provider was added to your config/app.php, but now that you've removed the package from your application ("Removing maatwebsite/excel (2.1.17)") you also need to remove the Service Provider.

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.

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.

Grails 2.3 unittesting with IVY resolver

If I do create-app with grails 2.3, create a simple spock unit-test, and change the configuration en grails to use ivy resolver:
grails.project.dependency.resolver = "ivy" // or maven
The unit test crashes with the following error:
| Running without daemon...
| Running 1 unit test...
| Running 1 unit test... 1 of 1
| Error Error running unit tests: org/hamcrest/SelfDescribing (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
... 7 more
| Error Error running unit tests: org/hamcrest/SelfDescribing
| Running 1 unit test....
| Running 1 unit test.....
| Tests FAILED - view reports in C:\ivytry\foobar\target\test-reports
Any ideas how to get around this? The reason why we need to use Ivy is that Maven doesn't seem to support custom remote repositories, where I need to specify username/password. -Besides in buildconfig, but I don't want my credentials under source control :)
EDIT (Solved): See comments!
The issue was because of the "infamous" intellij fix with idea 12 and grails 2.3 - restoring the "sources" and "javadoc" jar files, fixes the issue!