-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Travis CI: Support for Codeception tests #46
Comments
Codeception and Travis CI can be done, but "isn't for the faint of heart.". I also found WP Browser, a codeception wrapper specifically for WordPress. It still will need work to function on Travis, though, I think. |
I've gotten the ball rolling with WP Browser and a custom Codeception module for testing with WordPoints in WordPoints/hooks-api#92. However, I haven't tried to tackle running the tests on Travis CI yet. What I've found out with an initial foray is that Codeception itself is currently using Semaphore to run its WebDriver tests. I couldn't find the story behind that, but basically what it is doing is using PHP's built-in webserver to make it possible to run the web app: php -S 127.0.0.1:8000 -t tests/data/app >/dev/null 2>&1 & |
We may also need to exclude the Codeception test code from the PHP syntax checks on versions below 5.4. |
The closest thing that I've found to a working example of running a PHP webserver on Travis is this, for Drupal modules. There they are actually using Apache, not the built-in PHP webserver. (Related to that, I also found this ticket for Drupal itself, which notes that Drupal seems to still be using the built-in server, although there are times when it doesn't accurately mimic a real server.) Travis CI even has some docs on using Apache with PHP (found through this question on SO). Maybe that is the best thing to do. |
Codeception/Codeception#2265 seems to indicate that there are issues running phantomjs to connect to the builtin PHP webserver on Travis CI. Selenium server and Firefox did work for them though, so perhaps that's what we should explore. Or we could try to figure out why phantom JS can't connect to |
I also asked about why Codeception doesn't use Travis CI on their Gitter channel, but no response yet. |
Last night I happened to think that maybe the issue we were running into with the request for a password isn't related to PhantomJS at all. I wonder if instead it is the |
I just found this question on SO. It seems that the answer is to not use |
Because on Travis CI the password is empty, and using the short option will force the password prompt in that case. See #92, WordPoints/dev-lib#46
Tried passing the MySQL password differently, and got this:
I'm specifying the password as According to this SO thread, there could be many reasons for that error. My guess is that our best option to try next would be omitting the password options entirely. |
Now that I've got the MySQL password stuff figured out, I'm getting this:
I'm not sure if it is an issue with the server or the browser. |
Through WP#34693, I've just found https://github.com/10up/wp-codeception. It looks like something that we should investigate in addition to WP Browser. |
I just found this, and thought it might be useful for reference: https://github.com/SochaDev/codeception-ci-generator |
If we can't get this to work on Travis CI, we might have to try Semaphore or CircleCI, or something else. The only reason that I shy away from doing that is that I'd like to text against all versions of WordPress and PHP, which I don't think will be possible with the free plans offered by those services. Although on the other hand we can't test against versions of PHP below 5.4 anyway. Still, I'd like to test against each version of WordPress that we support. |
I finally discovered the issue with Travis CI not loading up the WordPress site (which was the cause of the login step failing as above). The issue was that I was setting the WebDriver URL to Now that that's settled though, it turns out that when accessed through the webserver this way, the WordPress site doesn't consider itself to be installed. The webserver redirects the request like so:
We're being redirect to I think that this is just because we have a |
When running the acceptance tests this is necessary. See #92, WordPoints/dev-lib#46
OK, that done, we are a step closer. define( 'WP_TESTS_DOMAIN', 'example.org' ); So this is what the site URL ends up getting defined as in the database. We can either update the value in the DB before running the tests, or just change that line in |
Hooray! It's alive! The only problem is that if we just modify the |
Wait until just before we are running the codeception tests. See #92, WordPoints/dev-lib#46
We had limited this to a single test for debugging. See #92, WordPoints/dev-lib#46
Actually, we use the tests bootstrap in our WordPoints Loader Codeception module. So we do need to use the constant, but I changed things so that we don't change the constant's value until after the PHPUnit tests have run. And now it is working great! We even discovered that one of our tests is failing because something in the Hooks API module is broken! |
We don’t need to use this to run our acceptance tests when we are using the PhantomJS browser, so starting it is just a waste of time. See #92, WordPoints/dev-lib#46
We wanted all the info we could get for debugging, but now that things are working, there’s no need. See #92, WordPoints/dev-lib#46
We aren’t debugging anymore! See #92, WordPoints/dev-lib#46
So don't check those files against 5.2 and 5.3. See #46
Our loading of the hooks API module was still hardcoded from when we copied the code from there. We now don’t load a module by default, but allow for it to be configured. See #46
This is supported natively in Codeception 2.2, but we provide back-combat for older versions and because there is a bug in that version. We actually still use an older version anyway. See #46
We’re running a *WordPoints* module. See #46
Fixes issues with running Codeception tests without a module. See #321, WordPoints/dev-lib#46
We weren’t actually catching exceptions as we were waiting for a reaction to become responsive before, because we are in a namespaced file, and we didn’t specify `\Exception` but `Exception`. It is better to reference the specific exception that we want to catch anyway. See #46
Fixes a bug in the Codeception bootstrap. See #321, WordPoints/dev-lib#46
The WordPoints autoloader isn't using initialization anymore. The method has been removed in favor of JIT registering of the SPL autoloader or loading of the fallback files if SPL is disabled. See #46, WordPoints/wordpoints#398
This is needed when running Codeception tests for a module. See #46
See WordPoints/wordpoints#17.
The text was updated successfully, but these errors were encountered: