Do people actually use unit tests for small/medium personal projects? Why/why not?

Do people actually use unit tests for small/medium personal projects? Why/why not?

Attached: 1563565931116.jpg (339x391, 38K)

yes. for me, writing unit tests is basically second nature at this point. if it's something you're just writing to say you wrote it and will never come back to it, then sure, don't. but if you're going to deploy it/actively use it somehow, there's really no argument for not writing tests.

not really, i just make some really basic tests to show people how you are supposed to use my the api

I would if I could get CUnit to compile on windows.

How do I get into unit tests? Do you just pass some fixed data in the functions and have it checked against an expected result, and throw an error if it's an unexpected result?

What languages do you use, out of curiosity?

Yes and just rerun the tests every time you push a change.

ye, you generally make a second project alongside your main one that contains your test cases. in each test case you assert a bunch of function returns against expected values. run that project and it will print out how many failed and how many succeeded. you do this before every deployment to see if anything was broken by recent changes. you can also make your unit tests before you write your code based on specifications and then make sure every assert passes, that's TDD.

Not that guy, but I usually make factories that return random data each time, pass it to the functions and then assert only the invariants that the result is supposed to have (ie never assert equality)

It's a bit more work and it might give tests that fail "sometimes", which is a bitch to debug, but it's fantastic to find hidden bugs on your production code

nope. because my code is already bugfree

ruby/js at my day job, but all my personal projects have been in elixir as of late.

no it is waste of time
IDE is my production environment and I fix bugs as they happen, i am not going to waste time

Attached: 3f4.jpg (812x800, 117K)

You can unit test in an IDE.

Unit test is a meme. Most companies only do shitty integration tests.

Based functional user

Why do they even make you do it then? I thought it was just for quality assurance when they outsource things.

HAHAHA you wish. Most companies hand things to manual qa pajeets who lie about testing and approve it for production, then when something big breaks in prod they act like they tested everything

My type checker takes care of it.

Another question, if you see a library or GitHub project that has extensive unit testing, are you more likely to use it?

Yes because if I can't conveniently write a unit test for something it means that something is some tightly coupled spaghetti code piece of shit and if I fix it now it pays off in the long run.
It's basically a retard proof way to validate your design. If it's unit testable it's at least good enough, otherwise it's shit even though
>but it works!

>How do I get into unit tests?
"I want to write a function foo that divides two numbers"
Your testfile will be:

test(foo).give(4, 2).expects(2)

A litle later you find a bug, turns out you can't divide by 0 for some reason

Your testfile will now be:
test(foo).give(4, 2).expects(2)
test(foo).give(4, 2).expects(Error)

And that's it. Add a test for however the function (or class, object, whatever) is supposed to behave. Add extra tests to ensure that the function properly throws errors in other cases. Whenever you find a bug you add a new test to catch that bug. And whenever you change anything you just re-run the tests.

The idea is that this makes regression impossible: the number of bugs will only go down.
In reality of course, you'll always be adding more code and introducing new bugs anyway, but the existing ones shouldn't come back.

I usually stick to integration testing on personal projects. Like testing full API responses instead of internal methods.

dumb pretentious faggot
dumb frogposter
true
t. clean shit up after pajeets

>Do people actually use unit tests for small/medium personal projects?
Only when I am trying to make a clone of adolf hitler from his DNA

Never did that besides running my own program. I also try mostly every variation of input when implementing a new function.

I write tests when appropriate. A library which will be used in many places gets far more tests than some webshit controller. If I'm writing something that's pushing my understanding of a concept (like implementing a complex algorithm or standard) there will be many tests so I can be sure I'm doing it right.
Code I'm very confident will work often goes totally untested. This is probably 2/3rds of the code I write. Testing is worthless because bugs almost never happen when I'm working within my comfort zone, and the bugs I do get are almost never something tests would have caught (like misunderstanding the requirements).
This goes out the window if I'm working in a dynamic language, because changing a type definition somewhere can silently break reams of code. Having basic sanity tests around all your shit becomes critical. This is the biggest reason why I've moved almost entirely to static typed languages. It's just less work in the long run.