Fork me on GitHub
#ldnclj
<
2015-12-18
>
thomas08:12:17

morning....

pupeno10:12:24

Good morning.

pupeno10:12:13

Our Clojure library, to-jdbc-uri, has tests and 100% code coverage. So far, all contributors, whenever they added a feature, they also added tests. I think Clojurians test more or are willing to test more than we give them credit for.

benedek11:12:01

i might be unpopular with this but I don’t think testing and code coverage has a huge value by definition. you always have to consider the context. of course for an open sourced library it makes sense to have unit tests and high coverage. so I think/hope Clojurians aware of this (perhaps obvious?) contextual nature of testing and do extensive testing when it makes sense...

pupeno11:12:09

@benedek: all numbers are useless when you consider it gaming them.

benedek11:12:44

not sure i follow @pupeno, sry

pupeno11:12:10

@benedek: why do you think testing and code coverage has no value by definition?

benedek11:12:53

i think it is very dependent on the context. I would possibly rephrase this and say that you need a fast/short feedback loop when doing development. in certain situations a big and well maintained test set gives the fastest feedback loop. and other situation such a test set is just too ‘expensive’ to create/maintain

benedek11:12:45

sry for the shameless self promotion but this blog post is kinda about this: http://benedekfazekas.github.io/2015/01/16/cheap-webapp-regression-testing/

pupeno11:12:27

OK. Never mind then.

pupeno11:12:36

You had something else in mind.

thomas11:12:18

@pupeno: @benedek I suspect you are both talking of the same thing...

thomas11:12:38

you just managed to word it very differently.

pupeno11:12:50

I’m just tired of the constant devils advocate. Whenever I say “Woohoo! I increased code coverage form 78% to 85%” someone points out how code coverage can be gamed and thus it’s useless. I find the same with BMI (Body Mass Index). Every time you use that concept someone will point out how it’s useless because for high performing athletes with less than 8% body fat and more muscles than an elephant, so it’s useless for everybody.

benedek11:12:23

sry @pupeno did not want to offend

pupeno11:12:30

I’m not offended simple_smile

pupeno11:12:04

I see more people not testing when they should than the other way.

agile_geek11:12:38

I don't just assume tests provide a feedback loop although this is the reason I use TDD when I don't have a REPL. What about tests as regression coverage during refactoring and as documentation of requirements? I have lots of first hand evidence of the later saving my bacon when trying to learn a new context.

benedek11:12:59

re regression coverage: exactly my point in the blog post. you deffo need something to catch regressions most of the times. only a unit test test might not be the cheapest option

agile_geek11:12:17

I agree. In my last role as CTO I had a discussion with my senior dev's around deleting unit tests once we had used them for feedback and providing that we could prove coverage in integration/functional tests.

benedek11:12:24

@pupeno: that is abs. a fair point. not contradicting that. but I guess we have to consider that coverage/test set comes with a price that is why sometimes ppl just decide not to invest in it

agile_geek11:12:10

However, I used to insist on rigorous test coverage with a less experienced team.

pupeno11:12:31

@benedek: something that I notice is that people say going from 0 to 100 with tests is so much slower, and they ignore that tests make going from 100 to 200 faster. They are an investment.

agile_geek11:12:54

@pupeno: I agree. But to @benedek's point we have to pay interest on that investment during change so we need to be careful to not double or triple cover the same functionality.

pupeno11:12:52

Sorry, I been burned by developers writing code that has a lot of coupling and no tests and now we have to treat the whole thing as a fragile tower that we have to stay away from because if we touch one thing, it might all collapse without us realising so.

agile_geek11:12:09

I have never found using high test coverage is slower long term than low test coverage...ever. As the time spent rewriting tests is never as bad as time spent debugging!

agile_geek11:12:31

However, I think, as with all things there's a balance to be struck.

agile_geek11:12:46

I think the balance needs experience and judgement.

agile_geek11:12:20

Therefore my default position will always be high test coverage at all levels

benedek11:12:39

I also find that coverage is able to shift the team’s focus from real problems, real user value sometimes. At a place I worked a couple years ago when the lead architect went to holidays he gave the stretch task to the team to increase the coverage from 85% to 95%. I felt it was a wasted effort tbh.

benedek11:12:47

@agile_geek: I abs. agree with the balance thing.

agile_geek11:12:17

As with all things, setting targets drives behaviours.

agile_geek11:12:43

I measure coverage and use it to have a conversation. I never use it as a target.

agile_geek11:12:23

If I want a target, what about features delivered or better ROI?

benedek11:12:21

@pupeno: don’t get me wrong. you deffo need something to catch regressions. no objection there from me

agile_geek11:12:22

I found when I had just two very senior dev's we could make decisions about when it was prudent to remove unit tests.

agile_geek11:12:56

In the other team with two more Junior dev's we had rigid adherence to TDD!

agile_geek11:12:11

With Snr's leading the way

pupeno11:12:50

In to-jdbc-uri (https://carouselapps.com/to-jdbc-uri/), we have just a single pure function that if it fails, your whole app just doesn’t start, that gets different arguments in production than in development, so it might fail in prod while not in dev. It’s very easy to test and having a full test coverage allows people to add more use cases without worrying about breaking the current one.

agile_geek11:12:58

As I said I'd always default to paying the price of changing tests over paying the price of releasing something I'm not happy with. Start with good test coverage and make decisions based on measurements. However, code coverage is not an indication of quality tests!

pupeno11:12:22

@agile_geek: for me, code coverage is a multiplier. code coverage multiplied by quality of tests = the quality of your test suite. No matter how high one is, if the other one is low, your result is low.

agile_geek11:12:19

I wrote a Web App two years ago and recruited a snr dev to take over dev from me. I had 2 hours to show her the basics of the project and how to build it then was off site for 3 days. I came back and she was making effective changes. I asked how she got on and she replied "I was stuck for an hour but then I read and ran your tests..." (readability is almost my primary measure of test quality)

pupeno11:12:54

@agile_geek: that’s why it would be better to measure the quality of tests by using those tools that automatically break your code and see whether your tests catch the error, but in my experience they are far from trivial to use and in most cases, reasoning about the test gives me a good enough estimate of the quality of the test. Specially in cases as simple as this: https://github.com/carouselapps/to-jdbc-uri/blob/master/test/to_jdbc_uri/core_test.clj

agile_geek11:12:58

P.S. Sorry for butting in but I get passionate about testing! I think all programming should be taught by writing tests as the first thing after the basic syntax.

agile_geek11:12:30

I am talking at Sunderland Uni in March about this very subject!

agile_geek11:12:57

@benedek: @pupeno fancy a face to face chat in new year about this?

agile_geek11:12:15

I could do with input to that talk from all perspectives

benedek11:12:36

@pupeno: that abs. makes sense

pupeno11:12:48

@agile_geek: I think writing tests first is a good exercise, I’m not an advocate of doing it 100% of the time because I believe sometimes we are in exploratory mode. Sometimes we are playing with the clay to see how it behaves, not trying to build a statue to specification. But I’m saying this to you, in this context, because I know you won’t use this as an excuse to write 0 tests. For developers that are just looking for an excuse to not write tests, I’d rather not give them some based on nuances they are going to ignore.

pupeno11:12:32

@agile_geek: face to face, yes.

pupeno11:12:02

With the caveat that I think everybody here is probably super smart and we can sit down and think up of thousands of use cases in which a general rule doesn’t apply and keep a good conversation going forever while it might be a better use of our neurons to sit down and code and/or test.

agile_geek11:12:24

@pupeno: I agree wholeheartedly (except I'm not smart, I've just been professional s/w dev for 28 years and made a lot of mistakes.) I really want some ideas of how to get across to post grads the importance of tests (we can discuss the drawbacks with a more mature perspective as well)

pupeno11:12:05

@agile_geek: oh, you are smart. And yeah, I’d be happy to talk about it and contribute whatever I want.

benedek11:12:01

agree with @pupeno both about his caveat and also I am happy to contribute

agile_geek11:12:40

Cool - I have your emails so I'll drop you a Doodle poll with possible dates and we'll do a chat over coffee or drinks in a pub in Jan?

benedek11:12:26

sounds good to me

benedek12:12:25

thanks for the good chat @pupeno @thomas @agile_geek . hope i was not too annoying 😉

agile_geek12:12:08

All opinions in this community are welcome and valid! I never hear ppl not speaking from some perspective of authority hard earned in experience and s/w battle scars!

thomas12:12:05

I appreciate the conversation as well. some good stuff in here.