Learning to code is hard. Learning to code with tests is harder. Let's practice this art together.
People
Repo info
Activity
Natalie J. Bennett
@njbennett
Tests can serve different purposes:
Design aids
Documentation
Regression checking And there's at least one more that I'm not thinking of at the moment... but the point being, a test that serves #1 but doesn't help #2 or #3 much can be a great test to write and then an equally great test to delete.
Rey Winters
@reywinters03
I'm okay with throwaway tests as long as people don't depend on them. Essentially you're providing saas for people ..
Kevin Lamping
@klamping
that's the trick though. anytime you put anything useful out there, people will start depending on it :)
Clint Hoagland
@vsComputer_twitter
I really like the point Natalie made about using tests to help design your code and then realizing that it's ok to delete them if they don't provide any regression safety
Natalie J. Bennett
@njbennett
What do you mean by "depend on them?" What does it look like to depend on a test?
Kevin Lamping
@klamping
just that they're using it for validation of something
Clint Hoagland
@vsComputer_twitter
I think if a test is telling you something you still want to know, it's implicitly not a throwaway test.
In my mind a throwaway test is something you just slap together to see how something is working and after you know you don't care anymore because you assume -for whatever reason- that it isn't going to change.
Clint Hoagland
@vsComputer_twitter
(or if you don't care whether it changes I guess)
Rey Winters
@reywinters03
Story time! So there was a developer who created a demo server to show off the newly created framework. Management decided (because of a time crunch) to use this demo server as the actual server. Needless to say it couldn't support a lot of users on at the same time.
Clint Hoagland
@vsComputer_twitter
Stories of Protoduction with Rey Winters
Rey Winters
@reywinters03
That said ... Throwaway tests should be separated and not publicized or at least explicitly stated that they are not written with best practices in mind :)
Haha
Clint Hoagland
@vsComputer_twitter
OK so what I'm hearing is not that these are what I think of as "throwaway tests" but rather tests that are either bad themselves, or that test something that is itself bad(?)
Rey Winters
@reywinters03
Both...?
but that's a good point ... What does a throwaway test look like to you
I wrote a test to tell me how many directories get returned by Directory.GetDirectories if I point it at my C drive. I did this only to find out how that method works; incidentally I found out how many (98). Now I can throw that test away because it's not testing anything I care about.
Not sure of the exact minute in the presentation he said it but he described what he does about them: moves them to a folder called "crappy-tests" and then replaces them with good tests when he has time.
Rey Winters
@reywinters03
Ahhh haha yes! To me your throwaway tests are utility scripts
Kevin Lamping
@klamping
@reywinters03 that story makes me crack up, because I can totally see it happening
Rey Winters
@reywinters03
@klamping it was based on a true story ... I believe the actual upper bound limit of users were two 😂
_
Kevin Lamping
@klamping
haha
Rey Winters
@reywinters03
How many of you have or had created testing frameworks that ultimately were not used by the people you created it for ...?
Kevin Lamping
@klamping
:raised_hand:
was shut down after a year of development and some use
Clint Hoagland
@vsComputer_twitter
<------- this guy
Rey Winters
@reywinters03
Sigh me as well ...
Rey Winters
@reywinters03
Does anyone here go into the SUT source code and change it to be more testable?
Natalie J. Bennett
@njbennett
"Does anyone here go into the SUT source code and change it to be more testable?" All the time!
I don't like to play the "best practice" card, but it's tremendously valuable. Often a small change in the production code can eliminate giant terrible swaths of test code.
Kevin Lamping
@klamping
agreed. as a front-end dev, I don't mind an ID here and there to make testing easier
Clint Hoagland
@vsComputer_twitter
This is a theological discussion I've argued with many many devs but my position is that code that is more testable is implicitly better and if you can change code to make it more testable it will make the code better. Full stop. So you should.
Kevin Lamping
@klamping
yep
i can see purists fighting back, but I think it's overwhelmingly worth the drawbacks
Natalie J. Bennett
@njbennett
What kind of arguments do devs have against changing code for test ability?
I work in a hardcore TDD shop so that viewpoint seems utterly alien
Kevin Lamping
@klamping
well, from an html standpoint, you're adding IDs that don't serve a purpose other than for testing
in theory that clutters up the code and increase page size
but that's a pretty far stretch IMO
Clint Hoagland
@vsComputer_twitter
IME bcz it breaks their OO design and "exposes class internals," usually because I want to do shit like inject a mock
Natalie J. Bennett
@njbennett
@vsComputer_twitter ... have they heard about dependency injection?
Clint Hoagland
@vsComputer_twitter
They have and they're against it. (Those that fight me on it)
Natalie J. Bennett
@njbennett
That's fascinating. I was taught dependency injection as an Important Technique as a baby coder, before I learned TDD or even really had the programming knowledge to get what DI was.
Clint Hoagland
@vsComputer_twitter
If you don't agree with TDD in principle and you don't think unit tests are important, dependency inversion doesn't seem all that important either.
Natalie J. Bennett
@njbennett
Hmmm... I agree that it becomes a lot more important if you practice TDD, but I've worked with developers who were suspicious of TDD but valued loosely coupled and swappable components. I've also seen TDD proponents argue that the design changes you make in response to wanting to unit test things are part of what makes TDD a valuable practice.
Clint Hoagland
@vsComputer_twitter
I agree with that. #choir
Rey Winters
@reywinters03
There have been many arguments about changing code for test ability