Issues with yii2-advanced functional tests - yii2

I am trying to run tests on the yii2-advanced-app off Yii 2.0.9
When I bootstrap the tests and run the basic default functional tests, I get the following error.
Tests\codeception\backend.functional Tests (1) -------------
E LoginCept: Ensure login page works
------------------------------------------------------------
1) LoginCept: Ensure login page works
Test .\functional\\LoginCept.php
[yii\base\ErrorException] Undefined index: SCRIPT_FILENAME
Scenario Steps:
1. $I->amOnPage("/backend/index.php/site/login")
#1 C:\xampp\htdocs\mtnt-2\vendor\yiisoft\yii2\web\Request.php:642
#2 C:\xampp\htdocs\mtnt-2\vendor\yiisoft\yii2\web\Request.php:602
#3 C:\xampp\htdocs\mtnt-2\vendor\yiisoft\yii2\web\Request.php:720
#4 C:\xampp\htdocs\mtnt-2\vendor\yiisoft\yii2\web\Request.php:670
#5 C:\xampp\htdocs\mtnt-2\vendor\yiisoft\yii2\web\UrlManager.php:231
#6 C:\xampp\htdocs\mtnt-2\vendor\yiisoft\yii2\web\Request.php:180
#7 C:\xampp\htdocs\mtnt-2\vendor\yiisoft\yii2\web\Application.php:75
#8 C:\Users\Aire\AppData\Roaming\Composer\vendor\symfony\browser-kit\Client.php:315
#9 Codeception\Module\Yii2->amOnPage
#10 C:\xampp\htdocs\mtnt-2\tests\codeception\backend\_support\_generated\FunctionalTesterActions.php:554
Time: 4.55 seconds, Memory: 12.25MB
There was 1 error:
---------
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
What I have learned so far...
I tried tracing the error and I realized the $_SERVER['SCRIPT_FILENAME'] is set in the bootstrap.php and in the config/functional.php. This entry script is correctly set to the /backend/web/index-test.php. However, the index-test.php file loads the codeception configuration for the acceptance suite.
What I have tried so far...
I added a new file to /backend/web called index-functional-test.php. In there, I changed the line which loaded the configuration for the acceptance suite to that of the functional suite. I had the tests use this new entry file, but I still get the same error.
I get the same issue when trying to test both the /backend and the /frontend. This is what informed this attempt
How do I fix this?

According to the discussion on the corresponding issue raised, this should be fixed when the new yii-app-advanced is pushed.
Basically, the tests are now decentralized. Each app folder would have its own tests folder. It is a structural change to the yii-app-advanced template. You do not have to wait for the Yii team. You can implement decentralized tests yourself.
Descend to the each app folder (backend, frontend, common, console, and others)
run ./vendor/bin/codecept bootstrap -ns "{app}\tests". So for the backend, you would run ./vendor/bin/codecept bootstrap -ns "backend\tests"
Make sure that the Yii modules are configured correctly.
Run tests

Related

GitHub Actions -- mark intentionally failed runs as success

Say I have CI tests running via GitHub actions. The program I test has a module that checks whether its input parameters are valid. Hence, I run a test where I intentionally provide improper input parameters, so the program catches this and exits with an error (exit 1).
Problem: I want GitHub Actions to mark this test as success. I am aware of continue-on-error: true for a run. Still, this will mark any failed run as success, no matter whether my program exits intentionally with an error due to improper input parameters (as described above), or because there is a bug in my code which then should actually return a failed CI test. So far I am manually inspecting the Actions logs but there must be an automated way to catch this.
Any ideas?

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.

Additional log output on NUnit test fail

Whenever an NUnit test fails during its execution (i.e. not when using Assert.*), I want to log additional information (I'm writing web tests and I am especially interested in the web page's current DOM).
How to specify a global exception handler in NUnit which is able to log additional information on NoSuchElementExceptions - test should still fail of course.
You could write an NUnit event listener addin that logs the information. See http://www.nunit.org/index.php?p=nunitAddins&r=2.6.3 and http://www.nunit.org/index.php?p=eventListeners&r=2.6.3. For a tutorial, see https://www.simple-talk.com/dotnet/.net-tools/testing-times-ahead-extending-nunit/.

HTML 5 - GRUNT BUILD : Fatal error: Object has no method 'compact'

I'm trying to build a project with GRUNT. it throws the following error,
Running "cuff:dev" (cuff) task
>> Building src/pages/home
Fatal error: Object home.less has no method 'compact'
src/pages/home/ -> home.less file,
section#home {
}
I didn't have any method in home.less. What i did wrong?. I can't understand the meaning of this error.
the info you provided is too less, my guess is dev target of cuff task has nested tasks probably something related to home task taking less as target, but grunt is not able to load less target. ( probably not defined at all or part of a grunt plugin you forgot to load )
That kind of errors are thrown when you call a target/task but grunt can not find/load it.
use grunt --help to load all available commands in your context ( commands from plugins are not shown by this command)

Strange errors when linking to libmariadb

I'm currently develop an Objective-C library that links to the MariaDB C connector. I believe there is a problem with the library, though.
Every time I execute my code I get very strange errors on the console. The -(id)init method of my library calls mysql_init(NULL) to initialise the library but as soon as I return from -(id)init I get the following errors in the console:
Object 0x10643df70 of class XXX autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Thing is, there is no multithreaded code being executed and if I run the same - (id)init without the call to mysql_init(NULL) the errors disappear. I believe the libmariadb library is causing these errors to appear. I don't get why though.
Do I need to build it with any special command line switches? Am I calling the right methods? I obviously used the MySQL online documentation as a guide.
Make sure you add this anytime you have a new thread:
#autoreleasepool {
//enter code here
}
Have you tried latest revision from launchpad?
Also try to build libmariadb with -DUNDEF_THREADS_HACK and
CMAKE_USE_PTHREADS:BOOL=OFF)
I was busy with other stuff for a while. I've since updated MariaDB to the latest version and, as far as I can tell, it works fine.