Increase your test coverage without writing tests.
Joking, but serious…
When you’re done reading this, have a good laugh, and then go write your tests!
Delete code that is not covered by a test.
This may seem like a silly concept but if you are able to remove “dead” code you are doing yourself a favor. Code that is not covered by a test might be broken. If it’s not running in production then there’s even a bigger chance that it’s broken. Leaving it around not only lowers your test coverage percentage but also creates a danger for someone in the future to start using broken code. You can always get your code back from your version control.
Add code to functions that already have tests.
You might not always have the opportunity to develop in a well tested environment. If you do — you should still feel good knowing that you are adding code to something that is tested. If you break it — you’ll know it. Unless of course the test is stupid… Then you should fix the test.
DRY-out code (hopefully with tested functions).
Combination of first and second approach give birth to a third! Try to notice situations where some code is unnecessarily duplicated. If there’s a function that performs the needed task — use it instead of copy/pasted code and your test coverage will go up. This is similar to deleting code except better! This is also applicable if you can use a well tested, 3rd-party library. Don’t reinvent the wheel!
Lastly, if you are simply looking for some boost in the confidence level that your code is doing what it should, but for some reason writing a unit test is not an option, there are still things you can do. Datadog recently released GUI browser testing which anyone, including non-engineers, can leverage to gain confidence of working code and alerting when something is broken. It won’t be as detailed or as fast as a good unit test, but it’s still a great tool.
Regardless of the test coverage percentage I always recommend writing testable code as a good engineering practice, even if it doesn’t have an actual test.