July 14
- pairing session with Parveen Khan
- when preparing for my pairing session, I removed all built directories and have the project build from scratch - which indeed proved my assumption that this would fix the profile service! :D
- in the beginning I told her about the background of the app, did a short run through of the app, explained what had been generated and what I added or changed, and what are potential next things to do
- Parveen wanted to explore the app and then do first changes together
- when Parveen went through the app, we noticed several things, she raised lots of great questions and she triggered several ideas what to do next
- TODO: the create / update challenge dialog showed the "influences" label in lowercase although it should be uppercase
- TODO: the journal entry index page should sort entries by default by date in a descending way with the latest one on top (right now sorted by creation date)
- TODO: for the index pages, the pagination thresholds should be defined, e.g. only showing 10 items per page
- IDEA: Parveen asked me whether I wanted to use the app to instantly publish journal entries to my blog - and I thought of that indeed! Or at least to have a quick copy button for the description field so I could easily copy it over to my blog posts and make my own life easier
- TODO: showing the challenge id for journal entries is not really useful, should rather show the tag instead (had that one on my list, yet it's great to hear confirmation from a different person that this should change)
- TODO: the challenge delete dialog should not only ask for confirmation of the deletion but also inform what will happen with potential related journal entries
- TODO: when trying to delete a challenge that still has journal entries, an unhelpful error 500 is thrown and the error message is not useful at all
- then we went on with making small changes to the app and seeing their impact
- for the challenge index view, we added a column for the hypothesis
- for the journal entry index view, we wanted to do the same, yet decided not to dive deeper here for now and solve that puzzle yet
- instead we changed the challenge detail view to not show the challenge id in the title yet the tag instead, and removed the tag from the rest of the detail page
- IDEA: we found it would be great to see related journal entries also in the challenge detail view
- Reflecting:
- Lisi: having a practice project offers a great and safe learning environment to get your toes wet
- Parveen: you need to have some idea of what app you want, then you start with small steps, then you get used to it, and you keep trying
- Parveen: having me as trusted navigator gave her the confidence to do these changes herself; also, I gave her the confidence by telling her "it's fine, don't worry", "we can just delete it, we have it under version control" and letting her do it on her own and try things out; Lisi: it was super useful to practice explaining things I learned (some of them recently), especially in a simple way, really helps my own learning; this is also something such safe learning environments are perfect for
- Parveen: was super great to both explore an app and make changes within just one hour! Now she understands why developers get into the zone, even forgetting to eat, doing things step by step; all this really helps to get into their shoes and create empathy
- Lisi: was really cool, got a lot of ideas out of the session :D
It was an awesome #pairing session. Im so motivated right now by what we did during this session.#power of #pairing 💪💪💪💪— Parveen (@Parveen_Khan10) July 14, 2019
Thanks @lisihocke 😊🙏 https://t.co/sGtrDoHnI4
July 14 (cont)
- finally got rid of outdated Java versions on my computer, only keeping OpenJdk 12
- looked a bit further into table default sorting
https://stackoverflow.com/questions/47022910/jhipster-sort-and-filter-a-table
https://github.com/jhipster/ng-jhipster/blob/master/src/directive/sort.directive.ts
https://github.com/jhipster/ng-jhipster/blob/master/src/directive/sort-by.directive.ts - had a first look into accessing other entities' attributes in the frontend
https://nehalist.io/working-with-models-in-angular/
https://nehalist.io/angular-7-models/
July 21
- tried to learn more about function calls in templates, trying to figure out where to declare the functions and how to call them from the template
https://nehalist.io/angular-7-models/
https://nehalist.io/working-with-models-in-angular/ - learned function calls are not the best idea in Angular, pure pipes are a better idea
https://blog.appverse.io/why-it-is-a-bad-idea-to-use-methods-in-the-html-templates-with-angular-2-30d49f0d3b16
https://dzone.com/articles/why-we-shound-not-use-function-inside-angular-temp
http://spraso.com/functions-in-angular-expressions-are-killing-your-performance/ - learned that I can call functions from the component in the related template
- interesting resources:
https://angular.io/guide/template-syntax
https://stackblitz.com/angular/kopnnveeqoal
https://angular.io/guide/displaying-data
https://angular.io/guide/pipes - custom pipe: learned I need to declare a separate module and import it in the module I want to use the pipe (e.g. challenge)
https://stackoverflow.com/questions/40457744/angular2-custom-pipe-could-not-be-found
July 24
- had a look at my team's production code to get some more clues
- read few resources
https://angular.io/tutorial/toh-pt2
https://angular.io/guide/cheatsheet
https://www.freecodecamp.org/news/48-answers-on-stack-overflow-to-the-most-popular-angular-questions-52f9eb430ab0/ - not sure if pipe is the correct way, yet seems worth trying more
- too tired to really learn and move forward, stopped
July 25
- not found solution yet
https://stackoverflow.com/questions/47117273/jhipster-filtering-entities-with-criteria-intended-angular-client-side-approa - interesting for work:
https://www.concretepage.com/angular-2/ngrx/ngrx-entity-example - Interesting reading:
https://medium.com/better-programming/a-generic-http-service-approach-for-angular-applications-a7bd8ff6a068
https://www.reddit.com/r/Angular2/comments/6vvjb6/direct_reference_of_service_instance_in_template/
https://stackoverflow.com/questions/42190002/i-want-to-convert-a-angular2-observable-to-a-class
July 27
- googled more, read more, tried more things; realized I have to read a lot more in detail to understand what I need to do
https://coryrylan.com/blog/angular-observable-data-services
https://blog.angularindepth.com/rxjs-understanding-expand-a5f8b41a3602
https://github.com/ReactiveX/RxJava/wiki/Transforming-Observables#map
https://www.raywenderlich.com/677-rxswift-transforming-operators-in-practice#toc-anchor-002
https://www.techiediaries.com/angular-rxjs-tutorial/
https://www.reddit.com/r/Angular2/comments/6qzkrt/how_to_dynamically_map_a_json_response_object_to/
https://stackoverflow.com/questions/36395252/how-to-get-data-from-observable-in-angular2
https://symbiotics.co.za/using-observables-in-angular-4-to-get-data-from-an-api-service/
https://medium.com/@luukgruijs/understanding-creating-and-subscribing-to-observables-in-angular-426dbf0b04a3
https://angular.io/guide/observables
https://codecraft.tv/courses/angular/http/http-with-observables/
https://blog.angular-university.io/how-to-build-angular2-apps-using-rxjs-observable-data-services-pitfalls-to-avoid/
https://angular-2-training-book.rangle.io/observables/using_observables
https://vegibit.com/how-to-make-http-requests-in-angular-using-observables/
https://github.com/ReactiveX/RxSwift/issues/435 - seems I got a step closer; still, the body values of the observable return undefined
https://stackoverflow.com/questions/46769042/subscribe-to-observable-is-returning-undefined
https://www.reddit.com/r/Angular2/comments/5u5orx/response_coming_as_undefined_inside_subscribe/
https://medium.com/@paynoattn/3-common-mistakes-i-see-people-use-in-rx-and-the-observable-pattern-ba55fee3d031
https://rxjs-dev.firebaseapp.com/api/index/function/bindCallback
https://redux-observable.js.org/docs/Troubleshooting.html
July 28
- looking at examples from work
- tried more things
- really need to read more deeper first
- nothing committed yet
August 11
- pairing with Shivani Gaba
- We planned to set out to pair on my Rest Practice project for which Shivani had feedback to share based on her experience with automated API tests.
- Shortly before the call I realized that the framework used in this project was relying on Java 8 which I recently had removed from my computer so we could not run the tests. After spending some time back and forth how to install OpenJDK 8 so I would not need the Oracle version, we decided to go through the feedback first. (Later I found this site where I could download a pre-built version of OpenJDK 8 for Windows: https://adoptopenjdk.net/)
- Instead of always using an explicit status code (e.g. 200), Shivani recommended to use predefined response status types so that the test becomes more readable and less error-prone.
https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/Response.Status.html
https://www.programcreek.com/java-api-examples/javax.ws.rs.core.Response.Status - In the current tests I asserted for certain body properties. Shivani recommended to implement a JSON helper instead which would provide utility methods like comparing the actual response to an expected JSON. This comes in handy especially if you have a lot more fields to test for. Also, this helper could offer generic convenience methods for creating a JSON object with certain parameters, adding and removing properties, or merging JSONs. Shivani offered to provide a sample - thank you!!
- Shivani recommended to store the complete response in a variable from which we can then extract headers, body, code whatever we need/want to use for each test only what's needed for the specific test.
- All endpoints were repeated in each test. Shivani would rather extract them as global enums (e.g. something like "Employee.GET_ID"), or at least declare them as variable, and re-use them, which would also increase readability and maintainability. If they change, you only need to change them in one place.
- One open question in the practice project was how to get a response without given/when/then when it's only about the setup. Shivani shared how she would wrap the setup in a custom method (e.g. a post method) to hide this implementation details from the rest of the test, which makes it more readable and more maintainable as well.
- At this point we decided to switch to my Journey project and have a look at how integration tests are done there. I explained the background and purpose of the project, what JHipster already brought with it, and that most of the tests got auto-generated and need improvement.
- We took the test for creating a journal entry as an example to start with. I shared that what surprised me with the generated tests was that they check the database directly instead of calling the API again to verify if the record really got created. This might be good as it's about testing the integration with the database, yet I was not so sure about depending on the database state here. Shivani did not work with Spring and its test context yet, yet this surprised her as well.
- Shivani shared that oftentimes integration tests are only used for the happy path, yet they are perfect for negative testing as well. For example, what if a mandatory field is not there? How do we handle that? We decided to implement a test for that to learn how it's done with the Spring framework. We discovered we could simply set a mandatory field to null before creating the DTO out of the entity which led to a bad request we could assert for.
- We learned more about how the Spring framework builds requests and uses matchers for assertions.
- We did not yet find a way how to provide custom error messages this way, like we could do for AssertThat().
- We found a more readable and re-usable way how to write the tests, extracting the expected response and the builder which made the test more lean. We could do this globally to reduce duplication.
https://www.logicbig.com/how-to/code-snippets/jcode-spring-mvc-junit-test.html - Reflection:
- I was really sorry for the rough start and the delay before we could work hands-on together. I was not as prepared for the session as I wanted to be, had a bad day. In the session I gained a lot new insights and good practices how to improve readability and maintainability of API tests. Thanks so much for sharing your experience Shivani!
- Shivani shared she was happy to pair with me. It got her really motivated to work on her own project idea now; something she had in mind for longer yet did not start yet :)
Thanks @lisihocke for letting me be part of your #CodeConfident journey. Can't thank you enough for inspiring me. It was amazing pair-up session & you're simply awesome.I hope we both learnt alot together & from each other. Would love to do this again ;) https://t.co/O5rFZAJ6xk— Shivani Gaba (@shivani_gaba_) August 11, 2019
August 15
- Pairing session with Gem Hill on unit tests
- Gem is starting her own testing tour and I felt super honored to be the first stop on her tour! :D For more details see https://letstalkabouttests.xyz/index.php/testing-tour/
- We started with me explaining the background of my Journey project, what it's supposed to do and also the code generation part, showing Gem what's there.
- We wanted to dive deeper into unit tests, and we had quite some generated tests to look into to understand them better and also critically question them.
- We decided to dive into the frontend unit tests using Jest as Gem's team is now also working with TypeScript and Jest, so this was a perfect match; and also for me it was great as currently I am working on frontend unit tests as well at work in a similar setup.
- I shortly introduced Jest and it's super useful watch feature where it runs all time in the background, running tests for changed files to quickly provide feedback while developing (my colleagues love that feature).
- We decided to look at the test for the challenge detail component first as most simple starting point.
- We went through the test from top til bottom, trying to formulate our understanding, making assumptions clear, voicing questions and parts we don't understand yet.
- Then we had a look at the actual implementation to map it to what we saw in the test.
- We noticed that the tested ngOnInit function only subscribed to the challenge, yet the subscription was not tested. This part is basic functionality provided from the framework - which is normally not what we want to test. So it's always the question where do we trust the framework implementation?
- We had a closer look at the mocking part. Interesting to dive deeper into would be the ComponentFixture class which is provided by Angular as fixture for testing and debugging components. This is something we're not using at work so I'm curious to find out more.
- The test is importing a test module which comes with a lot of mocks for services.
- When looking at the test module we came across the same number used for ids again, "123" - it seems the JHipster developers used the same number for all kinds of ids. To make sure our test is independent we changed the id for the used challenge and the tests promptly failed. Here we could see how Jest points out differences. I am also using the Jest plugin for Visual Studio Code which even shows the error inline. That's a nice feature, yet for me it's easier and quicker to see what went wrong in the console output.
- We decided to move on to another test and chose the assumed next smallest one, the one for the delete component.
- Here we came across the fakeAsync() and tick() methods which caught our interest. Once again we enjoyed the Visual Studio Code feature to hover over a method to get its description :) We learned that tick() simulates the asynchronous passage of time.
- We discussed spies which allow to mock return values of functions to stay independent from other parts of the app.
- Gem suggested to interact with the locally running app and see what's actually happening. This triggered the idea that I should install the Redux DevTools so we could inspect even closer. For now, we deleted a challenge and checked the respective requests sent. This way we saw that opening the delete dialog sends a GET request for the respective challenge - why? We had a look at the implementation and saw the defined selector. Was this the reason? We checked all references yet it was only defined here. We could not yet clearly see how things connect here, something to find out later.
- We had a look at the implementation for deletion and found a method to close the dialog on cancel. Once again we asked ourselves, is this worth writing a test for? Is it worth the effort of maintaining such a test? This should normally be code that's not touched very often so it's probably not worth it.
- We discussed mutation testing, an approach my team is currently trying out and Gem used quite often in the past. This is a great way to see if our tests are actually valuable and would detect issues and where we are missing tests. In my team we plan to use this as better guideline for what to write tests for than mere coverage which is not as helpful.
- Another part that caught our interest was that on deletion, an event gets broadcasted and the dialog closed. In the test, however, not the actual methods but respective spy methods had been used: dismissSpy() and broadcastSpy(). We assumed this makes the unit test even more "unit". Another point to dive into deeper!
- We moved on to the next test, this time the more complex one for updating the component. Once again, we started from top, including the imports. Gem called out that it's interesting that a HttpResponse is imported, came unexpected.
- We also once more saw that the test was named "Challenge Management Update Component", as it was generated - we both found it weird that the word "management" was included here.
- We had a look at the test for saving. It's really great that the generated tests included comments for given / when / then which made them easier to read and understand. This test, interestingly, also showed a comment for the tick() method which the other test lacked!
- We checked the differences for updating and creating a challenge, both on test and implementation side.
- What caught our eye was a boolean called isSaving. We wondered what it would do? We decided to first interact with the app again to see what's actually happening. A GET request, a PUT request. Nothing unexpected. Then we had a look at the implementation for isSaving. And we found this boolean is set to true only during the time the actual saving process is taking place. The value is only used in the tests. We both found this very weird. We would not expect this kind of implementation just for the tests, we never saw something like this in the products we worked on. We would only expect to add this during debugging to see what's going on; yet for the test it felt strange and it didn't feel to provide any value. I took a note to remove this implementation later on.
- Reflection:
- Time was flying and we soon got to the end of our 90min timebox.
- We both found it really nice to take time and dissect unit tests, challenging them, asking why, finding issues and questions while learning about the product. It proved again the point that you don't need to know code to the extent a developer does to be able to use your skills and strengths as a tester on code.
- I absolutely enjoyed our pairing session. When pairing we both bring our skills, expertise and knowledge to the table, and Gem and I had both overlapping and differing knowledge which fit together nicely.
- When pairing I realized how valuable it is to also look at the imports! I normally skipped them, yet we can already raise questions and improve our understanding here.
- It was great that Gem reminded me to interact with the real product again. I tend to focus too narrowly on what's in front of me which in this case is the code base, so it's easy to get disconnected. I noticed this several times now already during my code-confident challenge, catching myself on things I should know better. Gem pointed out this needs a context switch which is not easy. I agree, and it also increased my empathy towards my developers a lot more.
- Gem noticed me taking notes and realized she should also think about how to take notes better for her next stops on her testing tour.
- Gem found JHipster really intriguing. All the weirdness and bloatiness aside it seems to be really valuable to quickly kick-start a project and be able to learn with it. She plans to generate her own project for further learning purpose.
- We both found it super easy to pair with each other, even though we only met a few times in real life or virtually and paired only once before. Time flew by and we both were energized afterwards!
- I'm super looking forward to hearing more about Gem's testing tour and the lessons she will learn on her way :)
- TODO:
- install the Redux DevTools
- remove isSaving boolean
Just did my first #TestingTour stop with @lisihocke. Spent a wonderful 90 minutes looking at jest unit tests. Got some great things to think about and look into and has energised me even more for this tour :D— Gem Hill (@Gem_Hill) August 15, 2019
Had the pleasure of #pairing with @Gem_Hill again today, this time both on her #TestingTour as well as my #CodeConfident challenge. What a nice cross-over, dissecting unit tests & learning about the product together. Thanks Gem for having me, it was a super insightful session! 😃— Elisabeth Hocke (@lisihocke) August 15, 2019
What else?
The next Ministry of Testing Power Hour is coming up! I'm excited to be the one answering all your questions about pairing and mobbing. Just ask them at the club, and on August 22nd I'll answer them from my experience.
Also, the call for collaboration for European Testing Conference is open! Seize the opportunity to participate in this amazing conference next year by proposing your session ideas. The submission alone is worth it as you will get invaluable feedback.Curious about #pairing and #mobbing? How you can use these collaborative approaches to benefit testing or other activities? Having any questions around these topics? Then go ahead and ask them on the #MoT club, I'm going to answer them on August 22nd! https://t.co/E6DI6uLeb6— Elisabeth Hocke (@lisihocke) August 18, 2019
I just need to say this. I think @LisiHocke is one of the strong speakers with fascinating new perspectives. The detail and care she puts on her talks is inspiring. I'm a fan. Have been for a while, and just get more so. Give her more keynotes, please. <3— Maaret Pyhäjärvi (@maaretp) August 8, 2019
Why having sponsors is invaluable: yesterday @maaretp tweeted about me, advocating for me. 24h later I have 18 new followers and 2 "let's talk about you speaking at our event" conversations. THANK YOU Maaret. 🙏 And for the rest of us: let's be a sponsor, too - like Maaret. 🌟— Elisabeth Hocke (@lisihocke) August 9, 2019
No comments:
Post a Comment