Transcript from the "Testing" Lesson
[00:00:13] And eventually, you get a unit testing system up and running and it's fantastic, right? Go has the exact same thing except for its built in, right? So it has a testing already built in. The testing kind of sucks. We are gonna only rely on ghost testing library today.
[00:00:30] Cuz I'm just gonna use the most canonical items cuz there are assertion libraries forego that do make testing a lot nicer. So I can just like assert on stuff as opposed to doing this. Where I'm like, hey, I expected it to equal 7. If it doesn't have to explicitly say the error right here, it doesn't give you that nice printing out and you kinda have to individually test things.
[00:00:49] Which kinda sucks, right? If that's not exactly what you want. Rust of course, is significantly better. You test in the file. So you don't create a separate file for testing. And you do have to be careful about one thing with rust which is you gain the ability to test private interfaces, right?
[00:01:07] And so that is always really painful when you can, the more you test private interfaces what happens? Your code changes, your testing underneath the hood. And then now when you make a change to your code, you have like way more stuff you need to change because more tests break.
[00:01:20] So rust though, I think is one of the better ones for testing also provides more ability to make what I'd say is difficult decisions [LAUGH] with your life. So be careful about that. Rust test of code effectively looks like this. This is called a procedural macro or proc macro.
[00:01:37] And it does something magical to your code. You don't know what it does, doesn't matter what it does. And then you just say hey, this thing is the test. Does something magical to your code. Doesn't matter. If you can just say assert equal, and it will break if it doesn't equal.
[00:01:48] There's even a plugin or library you can download that overrides assert equals, and it will do like the full just style print out. If you have two objects, it'll say which properties aren't matching each other and you'll get that red, green and all that. So very, very fantastic.
[00:02:04] I would again, we're not gonna use any additional libraries. We're just gonna use what is available. TypeScript being the only one that you can't do that with because there is no testing available with TypeScript. And you're going to forget everything I said, right? I just said a whole bunch of stuff.
[00:02:18] We're all gonna forget it. So let's start building stuff, right?