Upgrading 2.0 codeception / test failure - webdriver

I upgraded codeception to 2.0 and then cept tests no longer work.
C:\Users\Project>php codecept.phar self-update
Codeception version 2.0.0
Checking for a new version...
You are already using the latest version.
Then I run build command
C:\Users\Project>php codecept.phar build
Building Actor classes for suites: acceptance, functional, unit
WebGuy includes modules: WebDriver, WebHelper
WebGuy.php generated successfully. 74 methods added
TestGuy includes modules: Filesystem, TestHelper
TestGuy.php generated successfully. 13 methods added
CodeGuy includes modules: CodeHelper
CodeGuy.php generated successfully. 0 methods added
And run the test
C:\Users\Project>php codecept.phar run acceptance TestCept.php
Codeception PHP Testing Framework v2.0.0
Powered by PHPUnit 4.1.1 by Sebastian Bergmann.
←[1mAcceptance Tests (1) ←[21m---------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------
--------------------
←[37;41m FAIL ←[39;49m
------------------------------------------------------------------------------------------------------------ --------------------------------------------------------------------------------------------
-----------
Time: 9.14 seconds, Memory: 6.50Mb
There was 1 failure:
---------
1) Failed to test in ←[1mTestCept.php←[21m (C:\Users\Projects\tes
ts\acceptance\TestCept.php)
←[37;41m ←[0m
←[37;41mFAILURES! ←[0m
←[37;41mTests: 1, Assertions: 0, Failures: 1.←[0m
As you can see the test doesnt work, no reason and there was no problem before the update.
Any suggestion will be welcome. thank you

was a bug with php 5.4 which is solved now
https://github.com/Codeception/Codeception/issues/1069

Related

react-native build failed after installing admob module

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1001 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
> Configure project :react-native-firebase_admob
:react-native-firebase_admob package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/admob/package.json
:react-native-firebase_app package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/app/package.json
:react-native-firebase_admob:firebase.bom using default value: 26.3.0
:react-native-firebase_admob:ads.consent using default value: 1.0.6
:react-native-firebase_admob package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/admob/package.json
:react-native-firebase_admob:version set from package.json: 10.5.1 (10,5,1 - 10005001)
:react-native-firebase_admob:android.compileSdk using custom value: 29
:react-native-firebase_admob:android.targetSdk using custom value: 29
:react-native-firebase_admob:android.minSdk using custom value: 16
:react-native-firebase_admob:reactNativeAndroidDir /home/muhamed-kveshkshaano/suck/node_modules/react-native/android
> Configure project :react-native-firebase_app
:react-native-firebase_app package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/app/package.json
:react-native-firebase_app:firebase.bom using default value: 26.3.0
:react-native-firebase_app:play.play-services-auth using default value: 19.0.0
:react-native-firebase_app package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/app/package.json
:react-native-firebase_app:version set from package.json: 10.5.0 (10,5,0 - 10005000)
:react-native-firebase_app:android.compileSdk using custom value: 29
:react-native-firebase_app:android.targetSdk using custom value: 29
:react-native-firebase_app:android.minSdk using custom value: 16
:react-native-firebase_app:reactNativeAndroidDir /home/muhamed-kveshkshaano/suck/node_modules/react-native/android
> Task :react-native-firebase_app:compileDebugJavaWithJavac
> Task :app:processDebugResources FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
37 actionable tasks: 29 executed, 8 up-to-date
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/home/muhamed-kveshkshaano/.gradle/caches/transforms-2/files-2.1/820765fbb4c63d086027395fb7f0dacc/play-services-ads-lite-19.6.0/AndroidManifest.xml:27:5-38:15: AAPT: error: unexpected element <queries> found in <manifest>.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 32s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
here is the error, the main problem is each i install admob module #react-native-firebase/admob, it throws this error after trying a lot i couldnt find any solution, it only happens after installing admob module except that it build well, anyone knows whats wrong with that module
I was with the same problem and it work for me
in android/app/build.gradle
defaultConfig {
...
multiDexEnabled true // added for admob problem
}
...
dependencies {
...
implementation "androidx.multidex:multidex:2.0.1" // fix firebaseAdmob
}
in android/build.gradle
dependencies {
classpath('com.android.tools.build:gradle:4.1.2')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.3.3'
}
now open the android folder in Android Studio and wait for gradle will update
when finish the gradle update run npx react-native run-android
downgrade all the rnfirebase libraries that you are using to less than 10.0.0 (admob 7.6.11 and app 9.0.0), as I show in the image

Azure Pipeline Error: vstest.console process failed to connect to testhost process

I am converting my azure pipeline to YAML pipeline. When I trigger the build, it gets failed on the Unit test step and gives the error as below
[error]vstest.console process failed to connect to testhost process after 90 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout.
I could not find a way to add the VSTEST_CONNECTION_TIMEOUT value anywhere. Could you please help me with this.
Here is the sample .yml I am using
- task: VSTest#2
displayName: 'Test'
inputs:
testAssemblyVer2: '**\bin\**\Tests.dll'
testFiltercriteria: 'TestCategory=Unit'
runSettingsFile: XYZ.Tests/codecoverage.runsettings
codeCoverageEnabled: true
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
diagnosticsEnabled: true
I would recommend you to use the dotnetCli task instead. It is shorter, clearer and straight forward (It will have the "same" effect as executing dotnet test in your console)
- task: DotNetCoreCLI#2
displayName: 'Run tests'
inputs:
command: 'test'
Even in microsoft documentation page, they use the DotNetCoreCLI task.
If the vstest task can run successfully on your classic pipeline. It should be working in yaml pipeline too. You can check the agent pool selection and the task's settings to make sure they are same both in yaml and classic pipeline.
1,Your Unit tests seem like running on Vs2017 in the yaml pipeline. You can try running the pipeline on windows-latest agent to run the tests on Vs2019.
If your pipeline has to run on specific agent. You can use VisualStudioTestPlatformInstaller task to download the latest version. Then set the vsTestVersion: toolsInstaller for Vstest task. See below:
- task: VisualStudioTestPlatformInstaller#1
- task: VSTest#2
displayName: 'Test'
inputs:
testAssemblyVer2: '**\bin\**\Tests.dll'
...
...
vsTestVersion: toolsInstaller
2,You can also check out the solution in this thread. As it mentioned in the solution deleting the entire solution folder, re-cloning the project. If you were running your pipeline on your self-hosted agent. You can try using Checkout in the yaml pipeline to clean the source folder before cloning your repo. See below:
steps:
- checkout: self
clean: true
You can also try adding below to your codecoverage.runsettings file under element <CodeCoverage> to exclude the microsoft assemblies as mentioned in the thread.
<ModulePath>.*microsoft\.codeanalysis\.csharp\.dll$</ModulePath>
<ModulePath>.*microsoft\.codeanalysis\.csharp\.workspaces\.dll$</ModulePath>
<ModulePath>.*microsoft\.codeanalysis\.dll$</ModulePath>
<ModulePath>.*microsoft\.codeanalysis\.workspaces\.dll$</ModulePath>
3,You can also try updating 'Microsoft.NET.Test.Sdk' to latest version for test projects.

System BadImageFormatException Format of the executable (.exe) or library (.dll) is invalid

CI pipeline taking about 50 min to complete and most of the time is consumed by the test. Have good number of unit test and data driven tests. Have decided to run test in parallel and the approach took based on this doc
Run Tests In Parallel In Build Pipelines
Idea is to split pipeline into 3 jobs
Build Job : builds the binaries and publish them to artifacts with
name pre-drop.
Test Job: downloads the artifact pre-drop, extract files, run tests parallel using VSTest#2 task
Publish Job: publish the artifacts to drop(for release pipeline).
Not sure if I was able to get my idea into .yml.
Test Job
- job : 'TestJob'
pool:
vmImage: windows-latest
strategy:
parallel: 2
dependsOn: 'BuildJob'
steps:
- task: DownloadBuildArtifacts#0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'predrop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: ExtractFiles#1
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/predrop/predrop.zip'
destinationFolder: '$(System.ArtifactsDirectory)/predrop/Extpredrop'
- task: VSTest#2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*tests.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.ArtifactsDirectory)'
vstestLocationMethod: 'location'
vstestLocation: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\'
otherConsoleOptions: '/platform:x64 /Framework:.NETCoreApp,Version=v3.1'
The issue is with VSTest task recognizing & running some tests but erroring out on other tests with following error on some of the tests
System.BadImageFormatException : Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Format of the executable (.exe) or library (.dll) is invalid.
The binaries from the first job has generated Microsoft.Extensions.Logging.Abstractions.dll as part of the artifact.
The document of BadImageFormatException Class says this exception is thrown in below scenario:
A DLL or executable is loaded as a 64-bit assembly, but it contains 32-bit features or resources. For example, it relies on COM interop or calls methods in a 32-bit dynamic link library.
To address this exception, set the project's Platform target property to x86 (instead of x64 or AnyCPU) and recompile.
So you can try configuring the VSBuild task to rebuild the project as x86 or x64. Check out this similar error in this thread.
If above changing the platform doesnot work. You can try this workaround to add a VSBuild task to build your project in job TestJob too. In this way, there will be no need to download and extract the artifacts in job TestJob. For below example:
- job : 'TestJob'
pool:
vmImage: windows-latest
strategy:
parallel: 2
dependsOn: 'BuildJob'
steps:
- task: VSBuild#1
inputs:
solution: '**/*.sln'
platform: "any cpu"
configuration: 'Release'
- task: VSTest#2
inputs:
...
You can also check out this thread.

class PHPUnit\Framework\ExpectationFailedException not found

when I try to run a failed test with this command :
./vendor/bin/phpunit
I get this Fatal Error :
PHPUnit 5.7.20 by Sebastian Bergmann and contributors.
PHP Fatal error: Class 'PHPUnit\Framework\ExpectationFailedException'
not found in /var/www/zend/vendor/zendframework/zend-
test/src/PHPUnit/Controller/AbstractControllerTestCase.php on line 444
Your version of phpunit is probably too old for your version of Zend. The class PHPUnit\Framework\ExpectationFailedException have been renamed in PhpUnit 6.X from PHPUnit_Framework_ExpectationFailedException to ExpectationFailedException
Please check your PhpUnit version: phpunit --version, it should be 6.X. Update it to the last version to avoid this error.
This is "fixed" by a script in Zend\Test called phpunit-class-aliases.php but it's not configured properly IMHO since it's in the autoload-dev section (meaning it doesn't propagate out to other projects.)
So, in your project composer.json, do something like this:
"autoload-dev": {
"files": [
"vendor/zendframework/zend-test/autoload/phpunit-class-aliases.php"
]
},
Then composer install
N.B. Zend\Test has a pull request that fixes this very thing, but they're saying it's PHPUnit's fault (Shame on you PHPUnit 4 for... idunno... having the wrong class name according to Zend\Test) So, I've done it instead: composer require illchuk/phpunit-class-aliases
This is a configuration flaw in zend-test. It consumes classes from Phpunit 6 but per it's Composer requirements, Phpunit before that version are OK to require:
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0",
Most likely as your system because of the PHP version does not satisfy the requirements of Phpunit 6, the next lower version was installed.
As the code in the base test case (https://github.com/zendframework/zend-test/blob/master/src/PHPUnit/Controller/AbstractControllerTestCase.php#L444) makes use of Phpunit 6 classes, I strongly assume that when the configuration flaw is made aware to the Zend-Test project, you won't be even able to install on your system any longer.
Therefore upgrade to a recent PHP version and then run
composer update
If you're stuk with the PHP version, downgrade zend-test to a version that supports an older Phpunit version. I don't know that project well, so it's just a suggestion, I don't know if such a version exists or can't even recommend one.
I filed a report, perhaps using that one class was an oversight or there is a less hard way to resolve the dependency: https://github.com/zendframework/zend-test/issues/50

Omnipay common abstract-class tests fail

I'm just looking at Omnipay with the aim of adding support for another gateway. After installing with Composer, I tried running the Paypal (as an example gateway) and Omnipay Common tests. With both packages, I adjusted bootstrap.php so that it could locate the composer autoload file. The Paypal tests run fine (green).
However, the common tests fail with 1 failure and 38 errors. All failures/errors are in AbstractGatewayTest, AbstractRequestTest, AbstractResponseTest.
This leads me to wonder if something changed in how PHPUnit or Mockery handle mocked abstract classes. I'm using PHPUnit 3.7.34. I have most recently been using PHPUnit 4.0.* for Laravel projects, but Omnipay requires 3.7.
composer.lock indicates I'm using Mockery 0.9.0. I'm running php 5.4.* installed via macports on OS X Mavericks.
Anyone have insight into what might be tripping me up? Thanks!
EDIT: Sample failure messages:
There were 38 errors:
1) Omnipay\Common\AbstractGatewayTest::testGetShortName
BadMethodCallException: Method Mockery_0_Omnipay_Common_AbstractGateway::getDefaultParameters() does not exist on this mock object
.../vendor/omnipay/common/src/Omnipay/Common/AbstractGateway.php:53
.../vendor/omnipay/common/src/Omnipay/Common/AbstractGateway.php:40
.../vendor/mockery/mockery/library/Mockery/Container.php:426
.../vendor/mockery/mockery/library/Mockery/Container.php:210
.../vendor/mockery/mockery/library/Mockery.php:71
.../vendor/omnipay/common/tests/Omnipay/Common/AbstractGatewayTest.php:12
2) Omnipay\Common\Message\AbstractRequestTest::testInitializeWithParams
Argument 1 passed to Omnipay\Common\Message\AbstractRequest::__construct() must implement interface Guzzle\Http\ClientInterface, none given
.../vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:46
.../vendor/mockery/mockery/library/Mockery/Container.php:426
.../vendor/mockery/mockery/library/Mockery/Container.php:210
.../vendor/mockery/mockery/library/Mockery.php:71
.../vendor/omnipay/common/tests/Omnipay/Common/Message/AbstractRequestTest.php:14
where "..." is my source code area.
Following Adrian Macneil's advice and explanation, I did a separate checkout of the Omnipay common files, and the unit tests indeed run green (successfully):
git clone git#github.com:omnipay/common.git
cd common/
composer update --dev && composer dump-autoload
vendor/bin/phpunit
yields:
PHPUnit 3.7.34 by Sebastian Bergmann.
Configuration read from /Users/ewb/startrib/omnipay/common/phpunit.xml.dist
............................................................... 63 / 161 ( 39%)
............................................................... 126 / 161 ( 78%)
...................................
Time: 94 ms, Memory: 8.00Mb
OK (161 tests, 258 assertions)
For the record, I adjust bootstrap.php as follows. This allows me to run the tests when they are included by Composer as dependencies. I'm new to both composer and Laravel (omnipay has nothing to do with Laravel), so my approach appears to not be best practice. Thanks for the advice!
The following version of bootstrap.php walks up its source tree (with a sanity limit of 5 levels) until it finds the directory containing vendor/autoload.php.
<?php
error_reporting(E_ALL | E_STRICT);
// Locate and include the composer autoloader
$sanity = 5;
$dir = realpath(__DIR__);
do {
$dir = dirname($dir);
$autoload = $dir.'/vendor/autoload.php';
} while ($sanity-- && !file_exists($autoload));
$autoloader = require $autoload;
// autoload abstract TestCase classes in test directory
$autoloader->add('Omnipay', __DIR__);

Resources