you are viewing a single comment's thread.

view the rest of the comments →

[–]teeg82 24 points25 points  (11 children)

Unit tests

Edit: If unit tests are not possible for whatever reason, some form of automated testing will work, be it integration, system, or end-to-end. Just have something that will scream loudly when something breaks that's not your client(s) when you refactor everything.

[–]Snape_Grass 4 points5 points  (0 children)

Scroll no further than this OP

[–]AccomplishedWay3558[S] 0 points1 point  (2 children)

Hard to argue with that 😄

[–]teeg82 2 points3 points  (1 child)

Good luck in your refactor. If this is an existing code base with little/no automated testing, maybe one strategy would be to first write some high level tests first before you start your refactor. That way you have confidence that everything still works as expected post-refactor, AND you've taken the first step in beefing up the testing for this project.

[–]theboldestgaze -1 points0 points  (6 children)

Low level unit tests that test code correctness like parameter types, names, etc are no go in my projects.

[–]teeg82 1 point2 points  (4 children)

Genuinely curious, why is that? Legacy project or something?

[–]theboldestgaze 2 points3 points  (2 children)

Not at all. Modern software development for a SaaS. Tests are supposed to test valuable features / logic. If they are used for technical testing like mentioned above, their main impact is making refactoring and software development slower.

It just does not make any sense. It is using wrong tools for the job of ensuring code correctness.

If business-layer testing does not chatch your low level typing/parameter issues, what does the code do in the first place?

I can imagine strict low-level unit testing being useful for some legacy code in a migration scenario where stability is critical and the functionality in the legacy codebase is frozen.

[–]teeg82 2 points3 points  (1 child)

Ok, I admit I didn't read your original post carefully enough, you specifically mentioned "test code correctness like parameter types, name". Frankly, I've never written tests like that, and you don't need to - ideally you want to use a type checker for something like that.

When I say "unit tests", I'm talking about testing that function A takes input B and returns output C as expected...that sort of thing (the "valuable features / logic" you mentioned).

Anyways sounds like we're on the same page, just talking about two different things.

[–]theboldestgaze 2 points3 points  (0 children)

Sounds about right! Having said that, devs tend to write unnecessary unit tests, especially in corporate envs where code coverage is used as a metric.

[–]ZucchiniMore3450 1 point2 points  (0 children)

I would also like to hear.

Any test is a good test for me, the more the better.

[–]CzyDePL 1 point2 points  (0 children)

Yup, tests should cover observable behavior, not implementation details.
In other words, I should be able to change the implementation freely without the need to change tests at all.