[yast-devel] Article on Testing
Hi, I read the article [1] and some of the references about testing and found it interesting and also disillusioning. ciao Arvin [1] https://blog.usejournal.com/lean-testing-or-why-unit-tests-are-worse-than-yo... -- Arvin Schnell, <aschnell@suse.com> Senior Software Engineer, Research & Development SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) Maxfeldstraße 5 90409 Nürnberg Germany -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
V Tue, 24 Jul 2018 10:41:04 +0000 Arvin Schnell <aschnell@suse.com> napsáno:
Hi,
I read the article [1] and some of the references about testing and found it interesting and also disillusioning.
ciao Arvin
[1] https://blog.usejournal.com/lean-testing-or-why-unit-tests-are-worse-than-yo...
Thanks for interesting article. I found it very interesting and as usually for good article I agree and disagree with some parts :) What would be nice if author adds some real measurement for some of his statements. Also I would like more clear definition of unit and integration how he see it. His definition of integration testing as "do not mock so much" is a bit weak. If I take it for YaST does unit test mean test for class and integration test for whole yast module? So mocking only external dependencies like other modules or underlaying tools? End to end testing is quite clear and I worry for YaST incredible expensive with our wide scope regarding architectures and various hardware setups. What I agree is that testing UI as unit tests is often pain and ideally should be just smoke test that it can display something and for verify manual testing is usually better and more confident. On other hand I disagree with statement about code quality and design with example about component A,B and C. If component is something that is externally visible, then for me it makes sense to have unit tests for its API and what's more - when changing component B to A and C, the cost for tests is still smaller then changing all the code that really use component B. So unit tests checking API stability and helps to understand that change of some behavior affects also all users. Of course if it is just internal component that is not visible outside, then it is a bit different situation. So thanks for sharing some food for brain. Josef -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On 07/24/2018 12:41 PM, Arvin Schnell wrote:
Hi,
I read the article [1] and some of the references about testing and found it interesting and also disillusioning.
ciao Arvin
[1] https://blog.usejournal.com/lean-testing-or-why-unit-tests-are-worse-than-yo...
Good article, I fully agree with most of the points. But it seems to be written in the scope of modern web development. That's a much more friendly environment for integration testing and other practices. On integration tests vs unit tests ================================== The article is right here. Before joining the the YaST Team, I seldom wrote unit tests for the components. Only for those which implemented tricky logic (like the BootRequirementsChecker, to show a YaST-oriented example). The biggest part of my tests were integration tests... But that was in the web development world, in which writing integration tests is a piece of cake. For example, in my last Rails (pre-YaST) project I could tests the whole stack as easily as this: https://github.com/openSUSE/travel-support-program/tree/master/spec/features To be more concrete, the following spec tests the rendered HTML, the Javascript behavior, the database update and the mailer (and all the interactions between those parts) by just describing the user actions and the application responses to them. Just describing the scenario like "go here", "click on that button", "this should appear". https://github.com/openSUSE/travel-support-program/blob/master/spec/features... We are far from having something similar in YaST, that can be written and maintained so easily and that can be run with a single command in some seconds. For proper integration, we need to reproduce a whole Linux system with some setup, to interact with the UI, to inspect the real changes in the system... We have nothing of that, so we fallback to unit testing, which admittedly implies a bigger level of mocking and provides a way lower ROI. On testing only the common cases but not the exotic ones ======================================================== I partially disagree here. I really believe that thinking about the boundary scenarios and the corner cases while writing tests for them helps a lot to write better code from the very beginning and to reduce errors. After all, the errors in the "happy path" are obvious enough to be found easily0, even manually. One of the things I like more about testing is the exercise of challenging your code with different situations. Of course, that implies an approach to testing based on scenarios and BDD, not just repeating the implementation with the RSpec syntax. Because when we write tests that are suspiciously similar to the implementation we are indeed just pleasing the code coverage stat with no real gain. Unit tests and the ossification of the internal structure ========================================================== I agree with the main point here. But again, that depends on the context for which the article is written. If you are just writing a web application to be used via browser, then you don't want the API of your components to get "ossified". You only care about the user-visible behavior. But an important part of the work in YaST is about writing APIs to be consumed in several parts of the project. Usually in other YaST modules living in another repository. And you really want those APIs to be ossified. The smaller internal classes and methods should be tested indirectly, using the more external API instead of calling every single method explicitly in the unit tests, but they should still be unit-tested. Cheers. -- Ancor González Sosa YaST Team at SUSE Linux GmbH -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Dne 6.8.2018 v 13:00 Ancor Gonzalez Sosa napsal(a): ...
To be more concrete, the following spec tests the rendered HTML, the Javascript behavior, the database update and the mailer (and all the interactions between those parts) by just describing the user actions and the application responses to them. Just describing the scenario like "go here", "click on that button", "this should appear".
https://github.com/openSUSE/travel-support-program/blob/master/spec/features...
We are far from having something similar in YaST, that can be written and maintained so easily and that can be run with a single command in some seconds. For proper integration, we need to reproduce a whole Linux system with some setup, to interact with the UI, to inspect the real changes in the system... We have nothing of that,
Not in YaST directly, but we have openQA. But the disadvantage is that a) It takes ages to get an ISO with your change for the test. b) You cannot easily run it locally or in CI as a part of the development process. c) It's hard to setup some scenarios, e.g. I can simply simulate a network issue in the registration module unit test by raising the Net::HTTPNotFound exception, in an integration test I'd need a testing proxy server. d) We cannot test too many scenarios as openQA is slow and does not have shortcuts. You cannot just test the storage proposal for scenario X, you have to go through full installation from the boot to the end. And that takes some time. So for me the unit tests are cheap and quick way for testing, we just need to find the right balance between the unit tests and the integration tests (openQA).
On testing only the common cases but not the exotic ones ========================================================
I partially disagree here. I really believe that thinking about the boundary scenarios and the corner cases while writing tests for them helps a lot to write better code from the very beginning and to reduce errors.
You usually test the happy path already during development, I believe we get only few bugs that something obvious does not work. I guess most of the bugs we get are caused by some strange hardware, complicated setup, users do unusual or even crazy things... So I consider it important to cover also the exotic cases. -- Ladislav Slezák YaST Developer SUSE LINUX, s.r.o. Corso IIa Křižíkova 148/34 18600 Praha 8 -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
participants (4)
-
Ancor Gonzalez Sosa
-
Arvin Schnell
-
Josef Reidinger
-
Ladislav Slezak