Would love to see you teach a beginner tutorial on unit testing. It would be really awesome to learn unit testing from someone with such vast industry experience.
test_like_button ✅ [PASSED] (1m21.69s)
Tests with random data generation are not reproducible. Not a very Staff thing to do.
Wow ... really useful, thank you so much for sharing. Also, subscribed :)
I just want to point out that while I agree that "one assertion per test" is a good rule of thumb, like all rules (yes, all rules) there are exceptions. Specifically, there are times when a successful outcome means that several things will be true at the end of the test, in which case it may be reasonable to assert a few related things together. One example of this would be testing a deep "Copy()" method. A proper deep Copy() should return a new object whose value (or values of key members) is equal to but NOT the same by reference as the original. This could mean asserting that the two objects are not the same reference, but then also asserting that key fields contain the same values. Since the conditions of "must be this and ALSO must be this" or "must be this, but must NOT be this" are inherently tied together in the correct behavior of the code, it is reasonable to assert each them in a single test.
Thank you my friend !
package smash.that.like.button had me dying laughing.
Like button: Fail. Original state = white outline, black fill. OnClick = Flashed red then turned white and solid.
How about for a string parameter testing blank, a normal size string and a string that is too long. I assume these would be 3 different unit tests, correct?
How do you write unit tests for a long class method having 1500+ lines of code? Also it has lots of global dependencies (in a form of class static methods). The test case I set up has 100+ lines just for mocking so as to get to the line of code I am asserting. OMG
I am a teacher and I've been trying to write tests for my students. However, there are not any good tutorials for testing the main method of a class. When I am teaching constants, I want to test that they are setting specific variable to a constant, and using the convention of capitalizing a constant variable. Would you be able to help with this?
I'd like to understand the difference among types of test doubles: mocks, stubs, fakes, dummies and so on. Many books waste many pages to try explaining the subtle differences among them, but without success... imho
I don't think using "random" is the best idea. Perhaps writing "fake" string, but one that doesn't change from run to run would be better.
You need to expand your definition of unit test, imo. A unit test needs to be standalone runnable from the command line. A unit test needs to be executed as part of your build pipeline. If those two things aren't true, you aren't really unit testing, you're just testing imo. Those two things impose a third restriction on unit tests. They need to be fast.
My like button turned white, how do I submit a bug report?
Can you give actual examples with code next time? This was great! Thanks!!!
Hi Cody can you recommend C# unit tests 'how to'?
Great content . Thanks a ton and much respect for your efforts here. Could you please share how you evaluate new software libraries? how to evaluate Android libraries to see how they fit the needs of an Android application. What kind of metrics do you generate and how ? If you could walk through with an example( like evaluating Room library or Hilt ).Specifically, How do you evaluate a software library for scalability. What tools or tests help? Thanks again.
wish you had code examples for everything you pointed out, like the factories.
@CodyEngelCodes