-
Notifications
You must be signed in to change notification settings - Fork 8
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
Cypress: Vanilla or Cucumber? #136
Comments
What do we want to use the feature files for?
Is it possible to use Cucumber for some things but Vanilla for others in the same suite?
What is the actual overhead of Cucumber?
How can we report our test results automatically to Zephyr in JIRA?
The README of
Have we had experiences where the feature files themselves have been really valuable?
|
Have we had experiences where the feature files themselves have been really valuable?I rewrote the When I added some new features (like tracked entity instance import/export) I wrote feature files to help me understand the exact requirements. BackgroundNo Cucumber or Cypress experience before working on the What is the actual overhead of Cucumber?@Mohammer5 mentions that the parsing time of feature files is significant. I don't get why. A parser cannot possibly be that slow. It's just matching our humanly readable Cucumber syntax into a list of already defined functions. Or am I missing something? Stubbed Cypress responsesI think we should be careful trusting passed Cypress results where the tests use stubbed responses (at least for apps). I worked on something else for a while before the |
@awgaan (copied from slack:) I assume it's the additional IO processes of reading files files. In my experience, that's always the slowest part when having to deal with parsing
And the above is happening for every single feature file. It doesn't matter too much with a couple of feature files. But with 100+ feature files and 500+ scenarios, this can take a while (a minute or two). I think, while this is a nuisance while waiting for CI to run the tests, I don't mind the extra time here too much, I prefer having the feature files, at least when just comparing this trade-off vs feature files in isolation. |
Ideally, I think our test suite should resemble the distribution mentioned here: https://kentcdodds.com/blog/unit-vs-integration-vs-e2e-tests. That means that the more realistic tests should make up the smallest part of our test suite (like cypress tests), because they're expensive. You also don't paint a wall with a tiny brush. It might be accurate, but it's not practical. Currently, repos like UI have a ton of cypress tests, and some unit tests. That should be the other way around. That is my core consideration for all our discussions about tests. So I think we should test most functionality in jest, and a (much) smaller portion with cypress. That is the practical, common approach. Whether we use feature files or not. If we want to guard all our features in cypress it's not going to be a practical test suite, but a slow, costly to maintain one. It might be precise to paint an entire wall with a tiny brush, but it's going to lead to fatigue, extra cost, and noone is going to want to paint anymore in the end. So realistically we can't guard all our features with cypress. So if we can't guard all our features with our cypress tests, then what we have left is a slightly more human readable syntax for a couple of integration tests. To me, that isn't worth it. |
@ismay what about apps? Would you also integrate most of the tests that currently leverage on cypress with jest instead? In regards to UI I 100% agree that we overshot with writing all the tests with cypress. But testing apps is a completely different scenario, which includes forms, "complex" interaction between user/app and app/backend, etc. This seems to warrant using browser-based tests. In that scenario I'm currently in favor of using feature files. The experience @awgaan had is exactly what I was hoping for as well (someone new to the app has little to no problems understanding how the app is supposed to function) |
I think the workflow that has emerged from using Cucumber is quite good, but we don't have to use Cucumber itself to use the workflow:
The end result is that we end up with documentation that our users can read. What we end up with Cucumber/Gherkin is documentation that a computer can read. In practice, I concede that I would write the feature first, then the tests. But I would use the documentation as guide for how the feature is implemented. |
Check out the article I linked. It's specifically about writing tests for frontend apps. The guy who wrote it is a former lead at Paypal, so he has experience with setting up decent test suites for frontend applications. I trust his judgement and have found following that advice to result in maintainable, reliable test suites. I don't see why we would diverge from that. |
@ismay so you'd prefer if we tried to write the tests that we currently have in some of our apps (import export, sms config) to be written with a non-browser-based tool (e. g. jest) instead? What would you use e2e for in our case (or do you think we shouldn't do that at all)? |
Maybe we're miscommunicating a bit. And this is diverging a bit from the core topic, but to clarify my position: basically I'm suggesting we follow best practice here, i.e. what's outlined in the article. That's what I'm basing my position on. Do you disagree with any of the statements made in the article, or do you feel the same? |
I very much agree with @varl 's statement above. The workflow is good, but can be achieved without Cucumber itself. As long as there are no strong benefits of using Cucumber I don't see why we should force everyone to use it. We also have to take in to consideration that we have a lot of different apps which have different levels of complexity, linearity, amount of user paths, legacy code, external dependencies etc which all affect what needs to be tested and how. Looking at Data Visualizer, which has high levels of all above (very complex, not linear, tons of user paths, lots of legacy code and external deps), and comparing that to a smaller greenfield linear app and forcing a technical solution on to both would not be a good idea. The workflow (as mentioned by @varl ) could still be applied though, but I don't see why a technical solution like Cucumber is neither necessary nor a good way to achieve this. |
The article made me thing about a few thing. What I'm trying to get to is: If we end up with more or less 10 cypress tests per app, then there wouldn't be a real need for feature files, so I agree with what you're saying @ismay IF we really will have a low cypress test amount. When talking about the usefulness of feature file, I think we have to zoom out a bit. So far we (as an org) don't have much experience with feature files except for writing them. To me it feels like the real gains show up later in the process, not right away. I think there are different things that feature files will do for us: 1. Zephyr test steps 2. We'd have human readable documentation
3. Workflow?
I have a very similar experience. Writing feature files first helps me structuring my thoughts and the information gathering process as it's so easy to just write text. This could be done with But I guess this is highly personal and others do not share the experience. 4. CI test failure reporting
With feature files, I imagine this to be very straight forward to provide that information Summary
I don't think we're talking about forcing a technical solution. If I remember correctly, we've said that having both vanilla and cucumber is an option and could depend on the use-case and/or context (e. g. DHIS2-XXXX vs TECH-XXXX, etc) I think this article also makes some fair points:
I guess this ties in with what @ismay refers to in the article (the amount of tests in the various categories). The workflow @varl has laid out is a BDD workflow (describe behavior/feature first, then write code). The important part of the quote above is: "key examples of behaviour and are not used to document every single edge case as tests". The conclusion of the author of the article is:
If our primary goal is to get a "high test coverage" or "broad test automation strategy" and we don't really want to focus on key features, then I guess we could even completely ignore cypress for now and switch to cli based tools |
Feature files shouldn't replace proper documentation and I think this could be a whole discussion on its own. |
There are different types of documentation. I'm not trying to suggest to replace all our documentation with feature files |
Thanks for the unit-vs-integration-vs-e2e-tests link @ismay . My take from the article is that you have to consider why you're writing tests and what you're trying to achieve. For the smaller greenfield apps one might want to achieve full test coverage for future use and make it easier to understand how the app works for a future developer (as also pointed out by @Mohammer5 's #2 point). However in the Analytics apps (most prominently in DV, but also in Maps and Dashboard) AFAIK the main goal at the moment is to enhance the regression testing and make up for the fact that we have very large apps and relatively scarce test resources. Using the articles painting analogy I'm trying to achieve a wide coverage by using a wall roller in random pattern across a large wall (like how a robot lawnmower / vacuum cleaner works) rather than systematically painting each square cm by moving in straight lines upwards down (like an inkjet printer). You can indeed write feature files for linear faeture-driven "inkjet testing", but how do you write feature files for the robot lawnmower? And will those feature files actually benefit any of the points @Mohammer5 made above? Obviously (if still going for Cucumber) the hybrid model would be the only viable solution here. Using vanilla for wide coverage legacy regression and using Cucumber for upcoming features in the future. |
Throwing this in here too. Deep integration of feature files into JIRA.
I don't want to derail the discussion, but it is important to note that feature files are defining behavior of an application, and they are strictly not a part of the test code implementation that tests the behavior. As long as you can describe the behavior of a feature, you should be able to implement e.g. property based or randomization test strategies in the test code itself to verify the behavior. |
@martinkrulltott I'd like to schedule a meeting and would ask you to demonstrate the part that you're testing. Maybe there's a way to test this without randomness and complicated mechanisms. I can imagine that we have different testing options. I also think that this is exactly what the article, that @ismay has linked to, includes a potentially valid point in this case:
Maybe a more generalized e2e test would suit this better rather than covering all possible combinations and integration tests would suit testing the combinations better |
The problem now is that I agree with everyone:
Nothing in that list exclusively requires Cucumber. My concern is that we are inventing a new system to avoid working with JIRA. This isn't entirely intentional, but we are definitely heading down a path here. Let's look at what we are doing:
The effect of this is that we are fragmenting information that should be in JIRA because it is the tool, for better or worse, we use to manage the entire development process over time for DHIS2. By positioning Cucumber between ourselves and JIRA we are ultimately not improving the problems we have at their root. For Cucumber to be effective for DHIS2 as a whole and not cause further fragmentation, we would need DHIS2 to embrace BDD. edit: updated with clarifications. |
I agree with what you're saying @varl, I'm not certain what your actual conclusions are.
|
Based on the discussion in the meeting #134 we need more time to properly evaluate if using Cucumber together with Cypress is something we want to heavily invest in.
This topic is to share experiences, discuss pros and cons, and see if we can figure out a way forward from here.
First off, let's state some questions we would like to answer. Post them below and I will add them to the list here.
To start off I will note a few from the frontend meeting.
Questions
Current usages
These are the usages I am currently aware of, let me know if an app or library is missing and I will amend the list.
Team Platform
Cucumber
Team Analytics
Vanilla
Cucumber
Team Tracker
Cucumber
The text was updated successfully, but these errors were encountered: