How to encourage team/senior developers to write mandatory unit testings?

Team background and my role

I am an iOS developer, working in a team of 6-7 members. There are only two iOS developers, including me. The senior developer is also the lead for iOS applications. I report to my senior developer and he reports to the manager. I am also excluded from most of the meetings with the manager, backend team, and QA. To make things even more clear, only this senior guy give me tasks and instructions on what to do. [I do share my thoughts with the entire team even though I m excluded most of the time. Some got attention.]

Unit tests

This senior iOS developer agrees on the importance of writing unit tests and can even talk about unit testings for the whole day. But in reality, I am the only one writing test cases. He does not even bother updating test cases when he changes classes written by me. Although he does not stop me from writing unit tests for his code, he does try to change direction.


In this situation, as a junior developer, how do I encourage my senior developer to commit to writing unit tests? Note: The manager is from a non-technical background.

  • It may be helpful to split the problem in half or more precisely identify where the problem is. Is the problem that there is no agreement that units tests are mandatory? Or is the problem that everyone agrees that unit tests are mandatory but people still don't do them? (If it's a bit of each, work on the first one first!) May 5 at 18:29
  • If I had a junior developer writing my unit tests for me, I wouldn't change a thing. Writing unit tests is hard work and if someone else wants to do that, I'd be fine with it. But, honestly, you don't have leverage. Instead, I would keep talking to your senior developer. You might be able to convince him that he needs to do that extra work. Or just accept that you have a very important role in the project - that of writing those tests.
    – David R
    May 5 at 19:00

I'd start by talking with your line-supervisor (the other developer), pointing out how you consider that unit testing is very important and that it would be valuable and beneficial to the entire project if tests were maintained just as closely as the source-code is. Try to convince him or her of the pragmatic benefits of this approach, and that they really ought to be "mandatory." That it would be worthwhile for everyone to agree to go to that "extra" effort. (Which it certainly is.)

Not everyone has yet had the experience of working on a project which did have a strong and up-to-date unit test foundation. They haven't yet had the experience of making an "innocent, unrelated" change only to have an "out of the blue" test-case suddenly fail – thereby preventing what would have surely been "a nasty new bug." (After all, "no one intends to write a bug!") It's a real eye-opener, but many developers have never yet experienced it for themselves. I presume that you have, so you've got a personal technical experience that you can share with the rest of them.


As you don't work for a technically-skilled manager, there's slim to no chance that you're going to be able to force the issue of writing unit tests with someone who's more senior than you. You'll have to basically wait things out until that person's not writing unit tests creates a disastrous situation for the entire team, and then you'll have some leverage to approach your manager. But any time before that, it would be hard for a non-tech manager to listen to you, listen to a senior dev, and determine that you were asking for anything of much value. The senior dev could make any statement on unit testing and end up confusing the manager on true levels of risk, and that could be enough to undermine your argument for a long time.

Maybe you're not working for the right company. Chances are that you didn't mention unit testing in the interview, and neither did the interviewers.


A possibility is take on dev-ops responsibilities (maybe the others are happy to off-load them to you). Once you have this power you can setup the whole build/release-process in such a way that it is mandatory to write one or more accompanying unit-tests with every ticket that is checked-in, or the build will fail.

  • 1
    If they do that, the lead developer will just tell them to cut it out. May 6 at 0:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .