I'm a newbie in Grails.
In the unit tests which are generated automatically by Grails, there is import for grails.test.mixin
import grails.test.mixin.TestFor
However, STS complains on Groovy:unable to resolve class grails.test.mixin.TestFor
where is this class defined, and how should I resolve this?
Thanks
As SĂ©rgio Michels suggests, run refresh dependencies on your project. If that doesn't work, run Project -> Clean... on the project.
Also, make sure that you are using a compatible version of grails (ie- version 2.0 or later).
Related
I have some unit tests and some classes that are related only to tests, like factories for my models, some extensions on mockito and others...
The issue is when I try to import those files from my tests I can just import them with relative paths, lets say I have this utilities:
test/src/test_utils/factories.dart
test/src/test_utils/mocks.dart
test/src/test_utils/mockito_extensions.dart
How I can not do it
But When I try to import them from my tests It can not find them with
import 'package:myapp/test_utils/mocks.dart';
or:
import 'package:myapp/src/test_utils/mocks.dart';
The only one that works
The only way to import them is by relative paths like:
import '../../test_utils/mocks.dart';
The question
I would love to understand what is happening here, why my tests cant find the test utils class on the imports and whats the best way to do this.
In the pub package layout the package: URI format is used for files under lib/. These are the "public libraries" that can be used from outside the package, and so they are the ones associated with the package name. Files under test/ are private to the package and don't need to be referenced by package name - they only can be referenced from neighboring files and directories so a relative import is sufficient. The package: URI format is designed primarily because it allows imports to other packages, to which there is no stable relative path.
See https://dart.dev/tools/pub/package-layout#public-libraries
Using relative imports is the recommended approach.
After setting up gradle properly, when i add for example #RunWith(RobolectricTestRunner::class) at the top of my test class, Andtoid studio does not import the class automatically when I click Alt+Enter.
When I manually type import org.robolectric.RobolectricTestRunner, i see that the class is recognized.
I have already done Invalidate Caches/Restart...
I am using Kotlin and AndroidStudio 4.0 and robolectric:4.3.1.
I had to use
androidTestImplementation 'org.robolectric:robolectric:4.3.1'
instead of
testImplementation 'org.robolectric:robolectric:4.3.1'
i my module build.gradle.
I got a Django project and its model, this module imported:
from push_notifications.models import BareDevice
I have installed push_notification library successfully but the problem is, this library don't have any function or class named BareDevice
Can anyone know about this? I just stuck with this project only for this BareDevice
I am reading the docs for ember-power-select testings here.
On the setup, it says:
import registerPowerSelectHelpers from '../../tests/helpers/ember-power-select';
registerPowerSelectHelpers();
...
I do not see ember-power-select in my tests/helpers/ directory. Am I supposed to install it separately, or was it supposed to come by default?
I installed ember-power-select by running the command suggested: ember install ember-power-select.
How can I use some of the power-select helpers like selectChoose(), selectSearch(), &c. like prescribed on the docs?
If you look ember-cli explanation about addons; there says "test-support/ - merged with the application’s tests/" and if you look at source code of ember-power-select there is a helper directory under test-support directory. This means when you install ember-power-select; this directory behaves like it is merged with your application's tests directory. It does not matter whether you see the tests/helpers/ember-power-select.js under your project. You can access it like this. Let's assume your project is named sample-project; then you can just import relevant function as follows:
import registerPowerSelectHelpers from 'sample-project/tests/helpers/ember-power-select';
from within your acceptance-test and call it before your test begin registerPowerSelectHelpers(); and you are able to use selectChoose(), selectSearch() as you wish.
Similarly you can just import integration test helpers as follows:
import { typeInSearch, clickTrigger } from 'sample-project/tests/helpers/ember-power-select'
So this is a really basic question. In all my blueprinted files, I see import statements such as:
import DS from 'ember-data';
Now I know that the build process is finding these in the vendor directory where bower installed them. Recently, I added moment.js, and I'd like to create a helper using it. However, there must be an additional naming convention that's being used because I can't simply
import moment from 'moment';
-- it claims it cannot find it in the tree merger. What is the right way to tell Broccoli where to find things when I want to import them?
Here is how I got things to work.
Install moment.js using bower install
Add the following line in Brocfile.js
app.import('vendor/moment/min/moment.min.js');
In your code, you do NOT have to import moment as it is NOT a ES6 module. You can call moment directly. For example,
var currDate = moment();
In the files where you use moment, don't forget to add the below comment as the first line of your file. You need to do this to avoid the jshint errors shown by ember-cli when you build the code
/* global moment:true */
Hope this helps!