¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io
Re: [TDD] Unit tests and parameter validation
A consumer must be told the specific semantics to expect. One way is to read the code. In the absence of code you must rely on documentation. Executable documentation in the form of code examples that
By Edwin Castro · #35380 ·
Re: [TDD] Unit tests and parameter validation
I tend to program in a more functional style these days, so you can write much more concise, if-less code ... if you want your data in a collection to be "valid", for example, you flatMap over it and
By John Goodsen <jgoodsen@...> · #35379 ·
Re: [TDD] Unit tests and parameter validation
Thanks John. Well I don't have to imagine it, I've seen which is what led to the question. :) Interesting perspective on contracts and the requirement to pass "correct" inputs (avoiding the use of
By Eb Alson · #35378 ·
Re: [TDD] Unit tests and parameter validation
Think in terms of the contract between the caller and the code. The code guarantees valid results, ONLY IF the caller guarantees they'll pass in valid parameters. So if passing a null is not part of
By John Goodsen <jgoodsen@...> · #35377 ·
Re: [TDD] Unit tests and parameter validation
Donald - If a test passes in the wrong input and fails initially, I see 3 general ways of getting the test to pass: 1. Have your test look for the exception that will be thrown by the code 2.
By Eb Alson · #35376 ·
Re: [TDD] Unit tests and parameter validation
Eb, I agree with Colin in principle, but wider than that I'd say, following Uncle Bob's rule of "no code without a failing test" pretty well ensures you will have tests which supply incorrect inputs,
By Donaldson, John <john.m.donaldson@...> · #35375 ·
Re: [TDD] Unit tests and parameter validation
Thanks for your responses. Colin - what if another developer would be using it (and not the originally creator). How does he/she know that passing in null (for example) is wrong?
By Eb Alson · #35374 ·
Re: [TDD] Unit tests and parameter validation
If this is internal code only and the code calling it is also testing then I not only would I not test it but I'd remove all defensive code guards as well. For example, a typical pattern would
By Colin Vipurs · #35373 ·
Re: [TDD] Unit tests and parameter validation
It depends on the language, but in general, I think it should be tested. brought to you by the letters A, V, and I and the number 47
By Avi Kessner · #35372 ·
Unit tests and parameter validation
Hello everyone - I'm curious to know thoughts on writing tests that specify the behavior of a method when its inputs are incorrect. Is this a common practice. How about parameter validation in this
By Eb Alson · #35371 ·
Re: [TDD] Unit testing in C++11
Good! :) 2013/7/25 Joakim Karlsson <joakim@...> -- Osias, o Osias [Non-text portions of this message have been removed]
By Osias Jota <osiasjota@...> · #35370 ·
Unit testing in C++11
Although there are an abundance of unit testing frameworks for C++ out there, I decided to learn some of the features available in C++11 by writing yet another one. At this point it's mostly for play
By Joakim Karlsson <joakim@...> · #35369 ·
Re: [TDD] Mocking collaborators that are third-party libraries
George - Answer is clearer and I am reminded of the two (complimentary) approaches. Thanks. <lists@...>wrote:
By Eb Alson · #35368 ·
Re: [TDD] Mocking collaborators that are third-party libraries
Eb, I tend to use a state-based approach (aka "Detroit style") so I'm usually verifying the result of the behavior. Often my test doubles are simple fakes (data sources) or stubs (data sinks, but
By George Dinwiddie · #35367 ·
Re: [TDD] Mocking collaborators that are third-party libraries
Thanks George. I am following that advice also (already) so very good to get affirmation of that. However, I realize my question was not clear enough so continuing from your answer, do you always
By Eb Alson · #35366 ·
Re: [TDD] Mocking collaborators that are third-party libraries
Eb, I wouldn't do that. I use adapters for third-party collaborators and mock my adapters to verify behavior. I also write integration tests for the adapter's interaction with the third-party. Steve
By George Dinwiddie · #35365 ·
Mocking collaborators that are third-party libraries
Hi everyone - What criteria do you use to determine if a collaborator that is a third-party should be mocked and the test should verify that the collaborator was indeed called when it was supposed to
By Eb Alson · #35364 ·
Re: [TDD] Statics and caches and mocks oh my!
There is a practice called "bebugging" (not a typo) in which developers deliberately seed the program with known bugs. The presumption is that testers will find them at about the same rate as unknown
By Russell Gold · #35363 ·
Re: [TDD] Statics and caches and mocks oh my!
I remember reading that NASA projects would not be released until a certain number of bugs had been found. This number was based on the project size and compared against bug statistics gathered
By James Shaw · #35362 ·
Re: Statics and caches and mocks oh my!
--- Keith Ray <keith.ray@...> wrote: That would, of course, inspire me to insert this gem every X number of lines: System.exit(-1) // TODO: Find and remove this "bug" during code review. . . OK;
By JeffGrigg · #35361 ·