Things Learned & Still Learning…
Varying variables. The flexibility to change the meaning of a variable throughout it’s usage in the application I find to be interesting. I don’t see it as good or bad, just that it is flexible. My concern could be that by doing this we could easily couple too much functionality into a single function. Thereby creating something that is both difficult to understand by looking at the code and to test. But given that I am new to this, maybe I am just stupid.
Cypress W/ Cucumber
Configuration. I am forever thankful to my cohorts and in this case specifically @alfredoig for helping me figure out how to install and configure Cypress with Cucumber. It was not as straight forward as I was initially led to believe when looking into this on my own. Tip that seems obvious but needs to be said; Be sure you are in the correct directory ;).
Browser Testing vs Headless. When running Cypress tests headless, the errors are usually very clear and help you to figure out what direction you need to go. However, take a moment to run the same tests in the browser and watch what happens. I have noticed on numerous occasions that a test will fail running headless but pass and work quite nicely in any one of the browsers Cypress offers.
False Failing. Tests will fail during creating other tests and functionality that aren’t actually failing. Let me explain.
- New functionality to add to the application.
- Create ‘Given’.
- Run test.
- See ‘Given’ test fail but also another random test fail…
- Curiosity and learning begins…
To attempt figuring out if this was a false failure, first thing was to check tests in the browser. When the tests also failed in the browser, I then took the error to google and the Cypress community in an effort to figure out how my lowly ‘Given’ was breaking a whole other functionality and test. After not being able to figure it out, I decided to return to safety and remove the ‘Given’ of the new test and see what happened. Everything passed. So now what? Put the ‘Given’ back in. Same failing results… Hmmm… Next experiment, finish the test and functionality. When that was done, all tests passed again. I was able to eventually find that others experience this error at random. More learning and research to come…
Things I do
Story Mapping. I started this idea of an app with a story map. I took the steps that I usually take to get something done and created a sticky note for each one. Then I sequenced them from left to right. After that, I began to go a little deeper into each step as to what I would do, or what had to happen to complete the step. Then I took an honest look at it and decided what I ‘thought’ would make a usable tool to solve my problem. Nothing pretty. No bells and whistles as you might say. Just the functionality I was looking for to solve my problem. Then I drew my horizontal line across the map. For anyone who hasn’t used a story map before, the things I ‘think’ I need to make this work go above the line, everything else goes below the line. Then I started creating stuff. If you have read my stuff before you may be able to guess what happened next. I said… ‘Now That I’ve Seen It…’
And this is where I like a story map but also see quite the amount of misuse with story maps. My map with what I ‘thought‘ was needed to make a usable tool changed. Yes, it can, does, will and should change. For me the horizontal slice across your map is not supposed to be treated as a locked in plan of what you will definitely deliver. Maybe you will eventually create all of those things for all of those steps in that map. Or perhaps, and for me preferably, while you create the things in the map and begin to use them, you will take an honest look at your map. Ask some questions.
- Is what we have on the map still what we need?
- Should something in the map be dropped for something else?
- Did we realize something in the time we were creating that last thing that we missed?
- Are we actually done?
There are a bunch of questions you could ask that would help you steer the thing you are creating. But not if you don’t stop to ask and answer them.
If you are interested in learning more about story mapping, event storming and domain driven design, here is a list of stuff that I have found helpful.
- User Story Mapping by Jeff Patton
- Passionate Produce Leadership Course by Jeff Patton
- Event Storming by Alberto Brandolini
- Domain Driven Design Distilled by Vaughn Vernon
TDD & BDD. My preferred design approach to creating software is TDD. I enjoy the flow, the smallness, the dopamine hits of rapid feedback, continuous integration and overall learning. Since I decided to use Cypress with Cucumber, I have interjected BDD into this design approach. Things I’ve noticed since taking this approach:
- I enjoy creating the tests with Gherkin G/W/T. The plain language of it gives my brain a break from code. The trade-off is there is an extra step of writing the Gherkin then creating the step definitions of the test. Making sure that text matches is another bit of pain. But the benefit of coming back to the test later and having it easily understandable to anyone whether they create software or not is nice.
- Writing tests backwards from the ‘Then’ (expected outcome) has allowed me to focus on the outcome. When I have a hard time having the test make sense, taking this approach allows me to feel that and what I am trying to do is not very well understood and probably far to big and complex.
- Naming makes a big difference. Using BDD has let me think more clearly about people that don’t know code reading my code. With this in mind I have found the value of explicit names. Abbreviations are pain. Unclear strings of text that don’t actually let me know what this code does, ex: “runJob”, are pain.
- Using the language of the domain. Directly related to explicit naming is naming with the domain language. If you use a different term than the business domain to describe the same thing, this causes pain. Same if you use the same term as the business domain but it has a different meaning. Pain. Pain by way of confusion.
Closing… For Now…