ldnclj

Find us on #clojure-uk
thomas 2015-12-18T08:45:17.000657Z

morning....

pupeno 2015-12-18T10:45:24.000658Z

Good morning.

pupeno 2015-12-18T10:46:13.000659Z

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.

thomas 2015-12-18T10:54:32.000660Z

@pupeno: well spoken

benedek 2015-12-18T11:02:01.000661Z

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...

pupeno 2015-12-18T11:05:09.000662Z

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

benedek 2015-12-18T11:06:44.000663Z

not sure i follow @pupeno, sry

pupeno 2015-12-18T11:07:10.000664Z

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

benedek 2015-12-18T11:08:53.000665Z

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

benedek 2015-12-18T11:09:45.000667Z

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/

pupeno 2015-12-18T11:10:27.000669Z

OK. Never mind then.

pupeno 2015-12-18T11:10:36.000670Z

You had something else in mind.

benedek 2015-12-18T11:11:05.000671Z

how so?

thomas 2015-12-18T11:13:18.000672Z

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

thomas 2015-12-18T11:13:38.000673Z

you just managed to word it very differently.

pupeno 2015-12-18T11:13:50.000674Z

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.

benedek 2015-12-18T11:14:23.000675Z

sry @pupeno did not want to offend

pupeno 2015-12-18T11:14:30.000676Z

I’m not offended :simple_smile:

pupeno 2015-12-18T11:15:04.000677Z

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

agile_geek 2015-12-18T11:15:38.000679Z

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.

benedek 2015-12-18T11:16:59.000680Z

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_geek 2015-12-18T11:18:17.000682Z

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.

benedek 2015-12-18T11:18:24.000683Z

@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_geek 2015-12-18T11:19:10.000684Z

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

pupeno 2015-12-18T11:19:31.000686Z

@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_geek 2015-12-18T11:20:54.000687Z

@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.

pupeno 2015-12-18T11:21:52.000688Z

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_geek 2015-12-18T11:22:09.000689Z

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_geek 2015-12-18T11:22:31.000690Z

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

agile_geek 2015-12-18T11:22:46.000691Z

I think the balance needs experience and judgement.

agile_geek 2015-12-18T11:23:20.000692Z

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

benedek 2015-12-18T11:23:39.000693Z

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.

benedek 2015-12-18T11:23:47.000694Z

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

agile_geek 2015-12-18T11:24:17.000697Z

As with all things, setting targets drives behaviours.

agile_geek 2015-12-18T11:24:43.000698Z

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

agile_geek 2015-12-18T11:25:23.000699Z

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

benedek 2015-12-18T11:26:21.000700Z

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

agile_geek 2015-12-18T11:26:22.000701Z

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_geek 2015-12-18T11:26:56.000703Z

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

agile_geek 2015-12-18T11:27:11.000704Z

With Snr's leading the way

pupeno 2015-12-18T11:28:50.000705Z

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_geek 2015-12-18T11:29:58.000707Z

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!

pupeno 2015-12-18T11:31:22.000708Z

@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_geek 2015-12-18T11:32:19.000709Z

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)

pupeno 2015-12-18T11:32:54.000710Z

@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_geek 2015-12-18T11:33:58.000712Z

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_geek 2015-12-18T11:34:30.000713Z

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

agile_geek 2015-12-18T11:34:57.000714Z

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

agile_geek 2015-12-18T11:35:15.000715Z

I could do with input to that talk from all perspectives

benedek 2015-12-18T11:35:36.000716Z

@pupeno: that abs. makes sense

pupeno 2015-12-18T11:36:48.000717Z

@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.

pupeno 2015-12-18T11:37:32.000718Z

@agile_geek: face to face, yes.

pupeno 2015-12-18T11:39:02.000719Z

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_geek 2015-12-18T11:41:24.000720Z

@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)

pupeno 2015-12-18T11:42:05.000722Z

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

agile_geek 2015-12-18T11:42:24.000723Z

😊

benedek 2015-12-18T11:45:01.000724Z

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

agile_geek 2015-12-18T11:50:40.000725Z

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?

benedek 2015-12-18T11:52:26.000726Z

sounds good to me

benedek 2015-12-18T12:01:25.000727Z

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

agile_geek 2015-12-18T12:03:08.000729Z

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!

pupeno 2015-12-18T12:08:21.000730Z

@benedek: me too 😉

thomas 2015-12-18T12:42:05.000731Z

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