ddev / ddev-ui

A not-currently-maintained user Interface that provides a graphical way of interacting with DDEV Local
https://www.ddev.com/
Apache License 2.0
20 stars 5 forks source link

Spike: Automation framework for DDEV Desktop Functional Testing #166

Closed mafriend closed 5 years ago

mafriend commented 6 years ago

End goal:

Find an automation framework that best suits functional testing for DDEV Desktop Timebox: 8hours

Questions to answer:

Needs:

Wants:

Frameworks to investigate so far:

dclear commented 6 years ago

@mafriend - i slotted this into current sprint. We can rollover, if needed. If you have time to do this and spin up issue for the next sprint, fantastic.

mafriend commented 6 years ago

Hello @cyberswat, @alkymst, and @dclear (and anyone else who is interested in providing feedback!), please review the below for a breakdown of framework specific benefits and drawbacks and let me know which drawbacks we are okay accepting! Spoiler alert: I'm leaning towards cypress with the cucumber processor (my thoughts/opinions are located at the bottom of the PR).

Spike notes Includes notes on all frameworks considered: https://docs.google.com/document/d/1nYYmdY3uesEanju3Xpw_4Hut6TtYlehKWgIZlwGspF4/edit?usp=sharing

Outcome We have two very good candidates for automation frameworks on our hands, each with their benefits and drawbacks. The common benefits between these languages are: they both provide documentation and automation functionality, they are both heavily supported in the community, and they both have lots of documentation on everything from installation to learning the framework.

Cypress also tests their own electron app with cypress tests: https://github.com/cypress-io/cypress/tree/develop/packages/desktop-gui/cypress/integration

My thoughts and feelings:

cyberswat commented 6 years ago

As of this morning, my vote is for the more traditional cucumber approach. Based on the research in this issue it sounds like Cypress has some potential, but looses points for being JavaScript specific and a less robust supporting community around topics like living documentation. Both of those items seem to translate to additional workload on the teams.

mafriend commented 6 years ago

That's a very valid point for using cucumber! We would have the ability to use a different language per project, but share a common framework/practice. Documentation and support around using selenium/webdriver with electron apps is pretty up to date and robust, which is a bonus! While I don't see cucumber fading into the background anytime soon, theres no guarantee about the level of support we could find with the cypress cucumber processor if anything started behaving poorly. I do really like the idea of being able to use one framework for unit, integration, and functional tests because that seems like less work overall, but I agree with you @cyberswat that the framework being language specific and less-robust support around living documentation could be additional work on team members.

I'm also much more familiar with the ins and outs of cucumber and would only need to brush up on whatever language we decided to pair with it 😎 Selenium conf in india just recently had a presentation on using selenium with an electron app! definitely something we could leverage if we decided to go with cucumber and selenium 🙆

dclear commented 6 years ago

Thanks for all of this work, Monica. To be clear, I am not a blocker here -- I trust whatever tool you smart people settle on, is the right choice.

dclear commented 6 years ago

@alkymst : can you review and weigh in? Thanks!

alkymst commented 6 years ago

I'm not sure it's an either or... However, I have the least real world experience with this.

My understanding, is the desktop app and web application for hosting present different requirements when it comes to what we need to test. It's not just functional or unit tests. We need the ability to fill forms, grab DOM elements, inspect there values, etc. As nice as the gherkin format is for functional tests, in reality I don't see it working for UI tests, filling forms, inspecting the DOM, or end-to-end tests to validate the UI. Snapshotting helps, but won't show you the true interactions. Cypress is solving a different problem all together. From their docs:

Cypress is not a general automation framework, nor is it a unit testing framework for your back end services. There are already great tools out there that do that. Rather, we specialize in one thing - creating a great experience while you write end to end tests for your web applications.

I feel like we need both types of tests.

  1. Functional: Both testing the CLI responses through the App, that responses from the cli functions are returning the appropriate responses, that projects are getting created, etc. - Cucumber
  2. End-toEnd: Actual interface testing - snapshots(if can actually record the session), testing the actual react data stores, performance measuring, rendering/UI issues, fill forms from the app and record responses. - cypress (possibly with Jest?)

The biggest thing I see when it comes to the UI is Cypress, or Jest run in the application loop allowing for a different level of testing that functional test do not really allow for. I get that it being JS limits it to only the app, but only the app has these issues we are trying to address. JS is the only way to actually test the interface as an actual user. As a developer you can run your end-to-end tests without having to trigger a CI process.

In addition, tests are really easy to write for a frontend developer.

Again, this is my lens as a frontend developer, and I'm totally onboard with whatever we use.

mafriend commented 6 years ago

Hey @alkymst !

Can you clarify what you mean when you say I don't see it working for UI tests, filling forms, inspecting the DOM, or end-to-end tests to validate the UI? With selenium webdriver (or something similar, we can use whatever programming language to do things like interact with the DOM, fill in forms in the UI, and validate certain UI elements are rendering.

I do agree with you that just using cucumber won't allow us for all levels of test coverage. Gherkin is intended to represent a very high level of acceptance criteria that help influence the other levels of testing and facilitate end-to-end UI testing. For example: We can take the gherkin from one scenario, automate it directly using a programing language to create the glue steps for the gherkin, and create an end-to-end UI test for that scenario. We will still need to write any necessary unit or integration tests though to make sure everything under the hood is working correctly. The end-to-end test in the above example may pass because the UI is unaffected, but there could still be an error when making an api call or storing something in the database (something that could be covered by a unit or integration test), so for the most complete and robust test coverage we'll need all levels of automated tests present.

Using your definitions above, I think I would categorize the tests thusly:

The idea of this not being an "either/or" choice is an interesting one! I would caution though that we only use one framework for end-to-end tests and one for other levels of testing (like unit or integration level tests). I know both hosting and local have their own unit tests that they use. Hosting has mentioned using bats and local has mentioned wanting to pursue that framework as well. Should we consider using cypress for integration and unit level tests while cucumber takes care of end-to-end tests? To me, that seems like a lot of effort but that's from my perspective as a tester!

As a heads up, you can run cucumber tests locally without kicking off a CI process! This is configured via the editor and can be used against pretty much any environment. It just needs to be specified in the test runner on an individual basis.

alkymst commented 6 years ago

Hey @mafriend!

Can you clarify what you mean when you say I don't see it working for UI tests, filling forms, inspecting the DOM, or end-to-end tests to validate the UI? With selenium webdriver (or something similar, we can use whatever programming language to do things like interact with the DOM, fill in forms in the UI, and validate certain UI elements are rendering.

If this is the case, then that works for me. I was worried about our ability to interact with the DOM, but if we can do it with a selenium webdriver than that works.

The idea of this not being an "either/or" choice is an interesting one! I would caution though that we only use one framework for end-to-end tests and one for other levels of testing (like unit or integration level tests).

I agree 100%

Should we consider using cypress for integration and unit level tests while cucumber takes care of end-to-end tests? To me, that seems like a lot of effort but that's from my perspective as a tester!

If we go this way I would say it's the other way around:

As a heads up, you can run cucumber tests locally without kicking off a CI process! This is configured via the editor and can be used against pretty much any environment. It just needs to be specified in the test runner on an individual basis.

Ok sounds good

dclear commented 6 years ago

Note from planning call: Monica will make the decision / call and we can close this out (spinning up any required issues for next steps).

mafriend commented 6 years ago

Hey folks! I've given this much thought and after playing around and doing some more investigation with cucumber and selenium, I think we should try cypress with the preprocessor and here's my reasoning:

I'm open to talk about this decision if others have questions (about testing, my thoughts, whatever!). Thank, folks!

dclear commented 5 years ago

this is completed; closing. Implementation will be handled under relevant issues / KRs.