I didn't want to open a bunch of issues at once, so I figured I could just write out my suggestions as one larger issue.
I've been working on migrating the test suite to GitLab CI and I've noticed some problems while doing it. I've also had significant trouble setting up the test environment locally. I intend to fix some of these myself, but I wanted to discuss them to see if I'm missing anything important that these changes would break.
./vendor/bin/robo driver:run-chrome, the ChromeDriver version that's installed should always be the latest version to make sure it remains compatible with newer versions of Chrome. (#7345)I->wait(x) from the acceptance test suite. Use waitForElementVisible instead. This makes the test suite take longer than necessary. (#7442)waitForElementVisible and similar. If a test fails, this unnecessarily adds 30-120 seconds to the test run. In special cases we can add a longer timeout, but for the most part we should always use the default 10 seconds timeout. (#7414)config.test.php file, which would be used to define configuration values for the test environment specifically (e.g. so you can run the tests on a separate database from the development site). Alternatively, maybe just config_override.test.php? (#7621)code:coverage Robo command work outside of CI. (#7622)config.codeception.yml.dist file and gitignore the file config.codeception.yml in the tests/_env directory. These can be used to set up a test environment locally without needing to mess with any files that'd be committed to the repo. (#7433).env files for use with testing, either phpdotenv or Symfony Dotenv. This is mostly useful for running multiple CRMs side-by-side on the same computer, and also because it makes it easier to figure out what the local environment variables are. (Issue: #7620)I've been working on improving the automated test suite in various ways and I was hoping I could get some information about whether people run the test suite and how they do it. I'd do this on the forums, but I expect I'd get more responses from people who'd actually run – or want to run – the test suite via GitHub.
My goal is to use this data to inform the improvements I'm making and to improve the documentation to make sure it focuses on the most common ways people run the test suite (or would want to run it).
If you could post a comment based on the following template, I'd appreciate it greatly. This is open to anyone who has contributed to the project! Please answer even if you don't think you're 'important' enough to :)
### What OS do you develop on primarily?
<!-- Windows, macOS, or Linux -->
### Do you run the test suite locally when making changes to the CRM?
<!-- Yes or No -->
### If you run the test suite locally, how do you do it?
<!-- Run it with just a local copy of PHP, with Docker, with a VM, or something else -->
<!-- Also, please mention whether you use Selenium Hub or a Selenium Docker container for the acceptance tests. -->
### If you're not running the test suite locally, why? And would you want to, if you could/if it were made easier to set up?
<!-- Explanation here -->
### Any other feedback here
<!-- Thanks! -->
Ok, let me try answering that...
Windows and Linux (Ubuntu)
No...
...
I don't do extensive developments, just occasional bug fixing. It's also easy to run the tests from Github, so I save myself the hassle of installing the tests locally. But I do think they would be nice to have locally if I developed more often.
I really value the role that automated tests have for our project, and I would love to see this evolve positively, and getting rid of the downsides of Travis. So a big thank you to you and to all others contributing to improve our automated tests system!
Linux
Have attempted to, got some going, generally only try while doing a bug or feature branch
Docker
Need to make sure they all run through the current setup.
docker-compose.yml file which just works out of the box would be delightful.
Something like
cd /tmp
wget https://github.com/suitecrm/docker-tests/docker-compose.yml
docker-compose run tests
GNU+Linux (Ubuntu)
Yes.
Have attempted to, got some going... The documentation was not so clear when I tried.
I only ran locally, unit tests
When we tried, the docs were not so clear... but we have no good reason to not run tests on every commit.... We are trying to setup our internal gitlab to run CI.
Linux (Debian)
No
I usually don't do extensive development, although, if the test suite were easier to set up, i would run it...
Linux
No
N/A
Most changes i do are not that big, so i trust in me :D
Debian/Ubuntu
Yes.
Locally, only the phpunit tests.
I would run the other tests if it would be easy to set up and would allow me to run a relevant subset of them.
I guess I should answer as well.
macOS
I've tried, but I haven't really been able to get it to run consistently.
I run it with a local copy of PHP. Docker for Mac has been too slow when I've attempted to use it (this almost definitely isn't as much of an issue with Linux).
I pretty much covered everything I want from the test suite in this issue's description, but essentially:
.env file.IMO, if you don't ever run the test suite outside of CI, you're significantly limiting the usefulness of having a test suite. I understand that people don't want to run the test suite locally since it can take 20+ minutes, but I mean even just running one test file so you can rapidly validate that the test works. This is especially important when a test breaks, because waiting 20+ minutes for CI to do it before you know whether your fix worked is a really long feedback cycle. (This is another benefit of randomization, since it allows you to verify that tests don't depend on each other and can be run independently).
@lazka @pgorod @isleshocky77 @Abuelodelanada @pribeiro42 @gunnicom thanks!
So based on the replies:
@Dillon-Brown @gymad @cameronblaikie could you answer the survey Qs just so I can make sure I'm getting as many responses from SalesAgility devs as possible? :)
@connorshea Yeah, one big want / need from my perspective is to make sure the tests are isolated and atomic and documented to show how to run just a single test pertaining to what you're trying to show is broken and or working on.
Ubuntu 18.04.
Yes, both the unit tests and acceptance tests through chrome-driver.
No local copy of PHP, I run everything through docker containers.
I don't usually run through the entire test suite before putting up PRs but I typically run through any I have created for the change or any pre-existing ones that I think might be likely to fail. Some things that would make the tests easier:
Would very much like to see as many people running the tests locally (SalesAgility devs too). With Travis starting to take 20+ minutes it's just not feasible to solely rely upon pushing changes up and waiting around for Travis to pass/fail.
Here are the slowest acceptance tests as of hotfix-7.10.x (only includes the the ones above 10 seconds):
| Test | Time (seconds) |
| ------ | ------|
| jjwg_MapsCest: Create a Map: | 30.14029598236084 |
| HistoryCest: See the due date field on Account History subpanel: | 22.763580083847046 |
| ActivitiesCest: See the due date field on Account Activities subpanel: | 21.289443969726562 |
| BasicModuleCest: Create a basic module for testing: | 21.02902102470398 |
| IssueModuleCest: Create a issue module for testing: | 19.52377200126648 |
| FileModuleCest: Create a file module for testing: | 19.29529094696045 |
| SaleModuleCest: Create a sale module for testing: | 19.074450969696045 |
| PersonModuleCest: Create a person module for testing: | 18.96099591255188 |
| UsersCest: View the collapsed subpanel hints on Accounts: | 18.88200807571411 |
| CompanyModuleCest: Create a company module for testing: | 18.772393941879272 |
| ModuleBuilderFieldsCest: Create a module for testing fields: | 18.65506100654602 |
| OpportunitiesCest: Create an opportunity: | 17.190773963928223 |
| ModuleBuilderFieldsCest: Deploy Test Module: | 16.77246403694153 |
| ContractsCest: Create a Contract: | 14.65644097328186 |
| CasesCest: Create a Case: | 14.458054065704346 |
| CampaignsCest: Create Non-Email Campaign: | 12.749990940093994 |
| AccountsCest: Create an Account: | 12.334502220153809 |
| EventsCest: Create an Event: | 11.36881709098816 |
| ModuleBuilderFieldsCest: Add relate field: | 11.041476964950562 |
Based on the data in the JSON report from here: https://travis-ci.org/salesagility/SuiteCRM/jobs/550989935
@lazka @pgorod @isleshocky77 @Abuelodelanada @pribeiro42 @gunnicom @Dillon-Brown @cameronblaikie @Mac-Rae @samus-aran thanks for the help! ❤️
I'm really happy with the progress we've made on the automated test suite :) It should be much easier to set up locally and I encourage everyone to do so whenever you make changes. It should also be far less flaky, much simpler to work with, and a bit faster.
You can follow the steps in the automated testing documentation to run the test suite locally now: https://docs.suitecrm.com/developer/automatedtesting/
If you run into any problems with that documentation, feel free to comment here or in the SuiteCRM Gitter with an explanation of the problem, and I'll try to improve the docs. 👍
Keep in mind that right now some of the acceptance tests can only be run once since they don't clean up after themselves, though I have a PR open to fix this that should hopefully be merged sometime this week. You should also note that these improvements mostly apply to hotfix-7.10.x, other branches should receive them in the next few weeks when hotfix-7.10.x is merged into hotfix and then develop.
I've split the remaining TODOs into separate issues:
config_override.test.php file (issue: #7621)code:coverage Robo command work outside of CI. (Issue: #7622)If anyone has any other suggestions for improving the test suite, I'd be happy to hear them.
Most helpful comment
@lazka @pgorod @isleshocky77 @Abuelodelanada @pribeiro42 @gunnicom @Dillon-Brown @cameronblaikie @Mac-Rae @samus-aran thanks for the help! ❤️
I'm really happy with the progress we've made on the automated test suite :) It should be much easier to set up locally and I encourage everyone to do so whenever you make changes. It should also be far less flaky, much simpler to work with, and a bit faster.
You can follow the steps in the automated testing documentation to run the test suite locally now: https://docs.suitecrm.com/developer/automatedtesting/
If you run into any problems with that documentation, feel free to comment here or in the SuiteCRM Gitter with an explanation of the problem, and I'll try to improve the docs. 👍
Keep in mind that right now some of the acceptance tests can only be run once since they don't clean up after themselves, though I have a PR open to fix this that should hopefully be merged sometime this week. You should also note that these improvements mostly apply to
hotfix-7.10.x, other branches should receive them in the next few weeks whenhotfix-7.10.xis merged intohotfixand thendevelop.I've split the remaining TODOs into separate issues:
config_override.test.phpfile (issue: #7621)code:coverageRobo command work outside of CI. (Issue: #7622)If anyone has any other suggestions for improving the test suite, I'd be happy to hear them.