Are there any fastlane actions or plugins that allow you to execute scripts between tests? - xctest

I've searched quite a bit today but have not found any solid yes or no.
I'd like to know are there any plugins or actions for fastlane that allow you to execute a shell script between each test execution.
The reason I ask is that, while testing I spin up a server locally with docker.
I'd like to be able to either clear this servers queues or tear it down and recreate between tests.

I have a fastlane plugin test_center that will allow you to provide a callback that is called between "test runs".
If you set the :batch_count parameter to the number of tests you want to run, the callback will be called after each batch.
That would allow you to make a shell call to docker to tear it down and spin it back up again.

Related

Automation job with jenkins is fetching tests from cache but not actually executing them. How to actually execute tests?

We have automation tests that run on jenkins slave, however some times job get's finished successfully showing 100% tests passed but what is happening actually is, these tests are being fetched from cache and not actually getting executed. We don't want this to happen as it is not reliable to depend on some old cache results. Suggest ways to avoid this, thank you.
I have nothing but to disable and enable job, re executing the job but of no use.
Quite strange, the jenkins in each execution runs a new suite, you can check the slave machine and then the browser by clearing the cache. Look closely at the build executions is the number #
check browser
clear cache
clean project on each run
check slave machine

How to run e2e tests automatically?

I really don't know how to ask question to Google about this, so I excuse me that it is naive.
Our team is developing SPA application in ReactJS. We also do back-end programming for NodeJS. Our project recently got more e2e tests. They are written using webdriver.io packages. Everything works as expected but circa 30 tests run about 50 minutes. It is too long to pause developer work and force him to run tests.
We came with the idea that now when we have so many tests, we need to run them on separate computer (other than a developer's laptop, further I call it e2e-laptop).
So I programmed a bash script and installed Ubuntu on a e2e-laptop. My idea is, that developer who wants to run e2e test logs in on e2e-laptop with ssh, runs specified script with arguments (eg: --rev= specific git revision the tests should run on, --email= where to send Allure report) and logs out. After tests are done he gets Allure report in his mailbox.
This all sounds to me OK, but not very well. It works - it is like a dirty MVP. But what I really would like to give my team is the web browser based UI that gives the features my script has. I can imagine this software is hosted on e2e-laptop, every developer can open its webpage address in his local browser. Then after authorization, there are options: run all specs, run chosen specs, send report and more. It would be the best if that software could also allow simultaneous running of tests commissioned by multiple developers.
What software I need?
You need a continuous integration tool. https://stackify.com/top-continuous-integration-tools/
I recommend Jenkins.
I would first try to run your selenium tests headless in a docker container on your laptop. Once you are able to do that, use that same configuration in your docker container running in Bitbucket pipelines. It could actually be the same container and the same scripts. Then, developers can just make a branch and work with the tests on that branch. If only a certain subset of tests need to run, then the developer can make the necessary changes on his or her local branch to run those tests and push it up to Bitbucket. This should help with the configuration https://github.com/SeleniumHQ/docker-selenium.

RN code-push: testing component that hooks into codePushStatusDidChange

I'm using the react-native-code-push codePush HOC, and running some logic in response to a codePushStatusDidChange event hook, in particular, when the status is SyncStatus.UPDATE_INSTALLED.
I haven't had luck finding out whether there is a way to emulate code push events when running in dev mode, to verify that our code is responding properly to the event hook. Is this possible, or is it necessary to release new versions to the code push server?
Side question: if the installMode is set to codePush.InstallMode.ON_NEXT_SUSPEND, is the event hook supposed to receive a SyncStatus.UPDATE_INSTALLED on the next restart? (I suppose once I can get the first question figured out, I can answer the second one on my own!).
#twelve17 Hi.
I can share my experience regarding testing & CodePush usage.
We have both e2e tests (detox + jet) and unit tests (react-native-test-utils + jest).
When we run our e2e tests we specify the environment and switch codePush setting in the root HOC:
checkFrequency: isTest()
? codePush.CheckFrequency.MANUAL
: codePush.CheckFrequency.ON_APP_START,
In this case (manual check & update), codePush doesn't do anything while the app is running. It works fine with e2e testing because you really don't need any codePush tasks while running them, definitely.
Regarding unit tests: we don't test the HOC itself (for now), we've just covered only some stateless components, so here I can only recommend you either skip such tests (because codePush is the 3rd-party lib) or write your own wrapper for any of its commands and mock/stub them in case of tests are running.

With Continuous Integration, why are tests run after committing instead of before?

While I only have a github repository that I'm pushing to (alone), I often forget to run tests, or forget to commit all relevant files, or rely on objects residing on my local machine. These result in build breaks, but they are only detected by Travis-CI after the erroneous commit. I know TeamCity has a pre-commit testing facility (which relies on the IDE in use), but my question is with regards to the current use of continuous integration as opposed to any one implementation. My question is
Why aren't changes tested on a clean build machine - such as those which Travis-CI uses for post-commit tesing - before those changes are committed?
Such a process would mean that there would never be build breaks, meaning that a fresh environment could pull any commit from the repository and be sure of its success; as such, I don't understand why CI isn't implemented using post-commit testing.
I preface my answer with the details that I am running on GitHub and Jenkins.
Why should a developer have to run all tests locally before committing. Especially in the Git paradigm that is not a requirement. What if, for instance, it takes 15-30 minutes to run all of the tests. Do you really want your developers or you personally sitting around waiting for the tests to run locally before your commit and push your changes?
Our process usually goes like this:
Make changes in local branch.
Run any new tests that you have created.
Commit changes to local branch.
Push local changes remotely to GitHub and create pull request.
Have build process pick up changes and run unit tests.
If tests fail, then fix them in local branch and push them locally.
Get changes code reviewed in pull request.
After approval and all checks have passed, push to master.
Rerun all unit tests.
Push artifact to repository.
Push changes to an environment (ie DEV, QA) and run any integration/functional tests that rely on a full environment.
If you have a cloud then you can push your changes to a new node and only after all environment tests pass reroute the VIP to the new node(s)
Repeat 11 until you have pushed through all pre-prod environments.
If you are practicing continuous deployment then push your changes all the way to PROD if all testing, checks, etc pass.
My point is that it is not a good use of a developers time to run tests locally impeding their progress when you can off-load that work onto a Continuous Integration server and be notified of issues that you need to fix later. Also, some tests simply can't be run until you commit them and deploy the artifact to an environment. If an environment is broken because you don't have a cloud and maybe you only have one server, then fix it locally and push the changes quickly to stabilize the environment.
You can run tests locally if you have to, but this should not be the norm.
As to the multiple developer issue, open source projects have been dealing with that for a long time now. They use forks in GitHub to allow contributors the chance to suggest new fixes and functionality, but this is not really that different from a developer on the team creating a local branch, pushing it remotely, and getting team buy-in via code review before pushing. If someone pushes changes that break your changes then you try to fix them yourself first and then ask for their help. You should be following the principle of "merging early and often" as well as merging in updates from master to your branch periodically.
The assumption that if you write code and it compiles and tests are passed locally, no builds could be broken is wrong. It is only so, if you are the only developer working on that code.
But let's say I change the interface you are using, my code will compile and pass tests
as long as I don't get your updated code That uses my interface.
Your code will compile and pass tests as long as you don't get my update in the interface.
And when we both check in our code, the build machine explodes...
So CI is a process which basically say: put your changes in as soon as possible
and test them in the CI server (it should be of course compiled and tested locally first).
If all developers follow those rules,
the build will still break, but we will know about it sooner rather than later.
The CI server is not the same as the version control system. The CI server, too, checks the code out of the repository. And therefore the code has already been committed when it gets tested on the CI server.
More extensive tests may be run periodically, rather than at time of checking in, on whatever is the current version of the code at the time of testing. Think of multi-platform tests or load tests.
Generally, of course, you'll unit test your code on your development machine before checking it in.

Automatic Jenkins deployment

I want to be able to automate Jenkins server installation using a script.
I want, given Jenkins release version and a list of {(plugin,version)}, to run a script that will deploy me a new jenkins server and start it using Jetty or Tomcat.
It sounds like a common thing to do (in need to replicate Jenkins master enviroment or create a clean one). Do you know what's the best practice in this case?
Searching Google only gives me examples of how to deploy products with Jenkins but I want to actually deploy Jenkins.
Thanks!
this may require some additional setup at the beginning but perhaps could save you time in the long run. You could use a product called puppet (puppetlabs.com) to automatically trigger the script when you want. I'm basically using that to trigger build outs of my development environments. As I find new things that need to be modified, I simply update my puppet modules and don't need to worry about what needs to be done to recreate the environments through testing for the next go round.