yii2 codeception doesn't generate unit suit - yii2

I red a ton of documentation and posts and it seems that almost everyone has problems with those yii2 codeception tests. My problem is that when I try to generate unit suit ./vendor/bin/codecept generate:test unit Login I get an error
In Configuration.php line 306: Suite unit was not loaded
What can cause this ? Have not found answer anywhere. Thank you!
EDIT - unit.suite.yml
suite_namespace: backend\tests\unit
suite_class: UnitTester
actor: UnitTester
modules:
enabled:
- Yii2:
part: [orm, email, fixtures]
- Asserts

The suite has to be specified. To specify it use -c backend
And the whole command should be:
./vendor/bin/codecept generate:test unit Login -c backend

Related

Django 4: settings.DEBUG not correct when running tests

I am trying to write a Django (4) test. It has to work differently depending on the DEBUG constant in my settings.py.
So I started with something like:
def my_test(self):
from django.conf import settings
if settings.DEBUG:
....
else:
....
I noticed the code never executed the first part of the if so I added:
print(settings.DEBUG)
And I noticed this prints always False. Even if DEBUG is set to True in my settings.py.
I tried with some others constants there (INSTALLED_APPS, ALLOWED_HOSTS) and all of them return the correct value.
Why is that? How to access the real DEBUG constant in my settings.py?
Adding --debug-mode flag solved the issue:
python manage.py test --debug-mode
--debug-mode
Sets the DEBUG setting to True prior to running tests. This may help troubleshoot test failures.

Test fails asp.net boilerplate. Abp.AbpException : There is no permission with name: Pages.Users

When I run web.mvc project (of asp.net boilerplate template) the following exception is throwed:
Abp.AbpException: There is no permission with name: Pages.Tenants.
I updated database. How to fix these problems? Thank you
You can check AuthorizationProvider of your solution, in SetPermissions method, Permissions are added to the context.

Codeception coverage report 0% though the test runs

I cannot set up the code coverage configuration, the report is always 0%. I'm using codeception coverage with two projects, the first one with:
Yii2
WebDriver module
Weird stuff:
I have two codeception.yml:
/tests/codeception.yml
/codeception.yml
c3.php is not in root. It is on /vendor/codeception/codeception/tests/data/claypit/c3.php
I'm not sure where I have to include c3.php
Like I'm not sure which codeception.yml is the right file, I have the same configuration on both files.
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: false
memory_limit: 1024M
modules:
config:
coverage:
enabled: true
remote: false
include:
- /controllers/*
c3_url: 'http://127.0.0.1/tmsO/#/'
I have the same problem with the second project, the differences are that I'm using:
Yii1
PhpBrowser module
Asserts module
REST module
Thank you in advance. I really need help.
When you use Codeception for acceptance Tests and using PHPBrowser/WebDriver you need remote coverage (remote: true). Therefore it will always say 0% in the console but will be saved in the _output directory.
On the remote site, the c3.php will collect all the needed data. So you need to include it in every call to your application. (for more information see https://github.com/Codeception/c3).
You can find the documentation for setting up the code coverage here: http://codeception.com/docs/11-Codecoverage

Sonar Unit tests report parameter - sonar.junit.reportPath vs sonar.java.junit.reportPath

I found that my Sonar instance 5.1 or 5.1.1 (with latest sonar-runner 2.x) stopped showing part of the Unit test info (Unit test widget) on the project's dashboard.
The properties I had were (in Gradle's sonarRunner > sonarProperties section):
property "sonar.junit.reportsPath", "build/test-results/UT"
property "sonar.surefire.reportsPath", "build/test-results/UT"
To fix it, I had to include the following properties as well:
property "sonar.java.junit.reportsPath", "build/test-results/UT"
property "sonar.java.surefire.reportsPath", "build/test-results/UT"
Just FYI: All my Unit tests reports go under build/test-results/UT folder, all Integration Tests result files go unedr build/test-results/IT folder and etc.
I'm wondering if this is due to Gradle version that I'm using (2.3) or is it due to a later version of SonarQube (4.5+) as I have both SQ 5.1 and 5.1.1 instance.
I know SonarQube team started Multi language support since SonarQube version 4.12
Since SonarQube 4.2, it is possible to run an analysis on a multi-language project.
Now, it raises a question. For Getting the same Unit test info for Groovy based projects, do I need to use:
property "sonar.groovy.junit.reportsPath", "build/test-results/UT"
property "sonar.groovy.surefire.reportsPath", "build/test-results/UT"
something like that if my project has Groovy code instead of java?
Searching "**sonar.java.junit.reportPath"** with using double quotes shows No results found in Google and it forces me to try and see google results if I can run the search again without using " double quotes (for this property).
Doing the same in SonarQube site "search box" shows:
No results found for sonar.java.junit.reportPath. Please try one of the following suggestions:
Though in Gradle, inside
sonarRunner task {
.. inside ..
sonarProperties {
... section ... where I define various sonar props..
}
...
}
I can define both sonar.junit.reportPath, sonar.java.junit.reportPath and similarly, sonar.surefire.reporPath and sonar.java.surefire.reportPath and while running sonarRunner task in Gradle, it doesn't error out. Thus it makes me believe that the property variables are valid.
There are also issues with running sonarRunner or stand alone sonar-runner command for a mixed Java and Groovy based project (i.e. source code in Java but tests in Groovy). Setting sonar.language=java,grvy didn't help. I posted this question on stackoverflow but so far I have no perfect result/answer on how to get a full fledged sonar dashboard up and running for a Groovy projects like I get for a Java project.
Groovy project - Sonar - Publish project and Unit + Integration Test code coverage data
PS: I have tried various values for setting sonar.. variables (as far a sonar source, tests, etc, etc properties are concerned, which they have mentioned on their site's docs section)
The only valid property to use as of now is sonar.junit.reportsPath which will tell the java sonarqube plugin where to import your result of unit tests.
For groovy, this is work in progress, see : http://jira.sonarsource.com/browse/SONARGROOV-2
All the other properties you mentioned do not exist and are not taken into account.

Are setenv hudson plugin variables accessible in status email?

I installed the SetEnv plugin and it works fine for getting the variables during a task.
unfortunately when i try to use the env variable in the resulting status email I have no luck at all. Is this supposed to work?
I've tried both $VARNAME and ${VARNAME} - neither of which get replaced correctly in the email.
The simplest way to use environment variables (or any variables) in your email notifications is by using the Email-ext plugin.
Check their "Content token reference" for specifics but in short you get much more sophisticated substitution. Heres a few I use regularly:
${ENV, var} - Displays an environment
variable.
${BUILD_LOG_REGEX, regex, linesBefore, linesAfter, maxMatches, showTruncatedLines} - Displays lines from the build log that match the regular expression.
${CHANGES_SINCE_LAST_SUCCESS, reverse, format, showPaths, changesFormat, pathFormat} - Displays the changes since the last successful build.
${FAILED_TESTS} - Displays failing unit test information, if any tests have failed.
The plugin makes it easy to define a base "global" template in the Hudson configuration then sort of "extend" that template in your job configuration- adding additional detail. It also allows you to route notifications more granularly based on the build status/outcome.
This is possible already. It looks like you're using the wrong syntax. As mentioned previously, the email-ext plugin has a specific method for accessing environment variables. Try putting this in the email body instead:
${ENV, var=VARNAME}
An alternative method would be to use Hudson's execute shell feature to echo the environment variable during the build and parsing for it using BUILD_LOG_REGEX.
For example, you could have this in the Execute Shell part:
echo "Output: ${VARNAME}"
and parse it in the email using
${BUILD_LOG_REGEX, regex="^Output:", showTruncatedLines=false, substText=""}
It looks like I will have to wait for this:
http://wiki.hudson-ci.org/display/HUDSON/The+new+EMailer