11 ms·
Two things: * Unit testing is different from integration testing. They aren't interchangeable. Mainstream languages offer units of code s.a. a function, a cl
by crabbone 1mo ago
Two things:
* Unit testing is different from integration testing. They aren't interchangeable. Mainstream languages offer units of code s.a. a function, a class, a module and so on. Unit testing refers to testing the functionality implemented by a single such unit. There's no expectation that it will prove the entire program is correct, but it helps the developer to identify errors on the smallest testable level. Integration is a kind of testing that involves multiple testable units. In the ultimate case, it becomes end-to-end testing when the number of units tested are enough to cover functionality expected from the entire application rather than its individual parts. Even at this point, there's no expectation that the testing will prove the program is correct (unless the test can be made exhaustive), but it can prove that the program is correct sometimes.
* Encoding desired sequence of behaviors into a type doesn't prevent errors, s.a. in your example: FileNotFound. It's either a bad example, or there's little value in encoding the entire chain of expected events into a type.
I think that what parent referred to is what's also known as https://en.wikipedia.org/wiki/Law_of_Demeter https://en.wikipedia.org/wiki/Law_of_Demeter . The reason for it you can gleam from the Advantages section of the linked page: in short, less knowledge of the unrelated components makes the replacement of individual components easier, therefore decreasing maintenance efforts. It also implies benefits in creating interfaces with simpler / more common types that are less likely to change over time s.a. to minimize the potential need to alter unrelated objects in order to replace / modify the desired one.
You could argue that this leads to loose coupling (same as, eg. the world of microservices) and makes the system more difficult to analyze as a whole. But it seems like that people who embrace this approach are willing to trade system-wide guarantees for their ability to evolve or to patch the system at low cost.
- mrkeen 1mo agoUnit testing: Well, which is it? Testing a function, a class, or a module? I didn't give my definitions of testing. I said when you go out into the OO worldview, different people will call it different things, so ignore it, it's not important. Sometimes one person will call it two or three different things. E.g. Unit testing is a function testing vs. unit testing is class testing. Demeter: That's the thing I called wishful thinking. Encoding desired sequence of behaviors into a type doesn't prevent errors: That's the value proposition of Choreographic programming. If it's wrong from the outset, simply disregard it.
- crabbone 1mo agoIn order for you to understand what a "unit" is, you need to first consider that there are different languages with different units. The definition of a "unit" doesn't give you a concrete size, it gives you a size relative to the language or even the project you are working on. It will be something the programmers working on the project will have to agree on, when they set to design unit tests. Other examples of relative units: pixel (they don't have a fixed size in software), portion (as in cooking: it will depend on the place the food is served, intended audience), decibels (they don't measure the absolute volume of sound, they measure how one volume corresponds to another). But... who am I kidding? If you were intelligent enough to understand the subject of this thread, you were certainly intelligent enough to understand what a "unit" is in unit testing. You are not arguing in good faith. > Sometimes one person will call it two or three different This is poor ability to reason: if two people disagree it doesn't follow that everyone is right. > If it's wrong from the outset, simply disregard it. This is poor ability to reason: criticism of a concept is just as valid of a way to discuss the subject as is praise. Nobody should be told not to discuss the subject if they think the subject is defective. > Demeter: That's the thing I called wishful thinking. While providing no arguments and no evidence.
- throw1234567891 1mo agoDefine a unit.
- crabbone 1mo agoI did it in the post you replied to.
- throw1234567891 1mo agoNo, you defined what you mean by "unit test". What's the unit.
- crabbone 1mo ago> Mainstream languages offer units of code s.a. a function, a class, a module and so on. Unit testing refers to testing the functionality implemented by a single such unit.
- rrook 1mo agoI've been working on a language that codifies a single abstract _situated_ unit of computation. It sits at the intersect of memory, process placement, callstack, lifetime, and domain graph. Because it's the only unit of structure in the language, everything is layered recursively, which means the compiler can reason about the codebase at layers that we'd normally leave to third party tooling, ci, or other infra: https://hale-lang.org https://hale-lang.org