Click here to Skip to main content
14,450,502 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Eddy Vluggen26-Nov-19 7:32
professionalEddy Vluggen26-Nov-19 7:32 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Maximilien26-Nov-19 7:35
MemberMaximilien26-Nov-19 7:35 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Sander Rossel26-Nov-19 10:32
professionalSander Rossel26-Nov-19 10:32 
GeneralRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Rick York26-Nov-19 11:29
mveRick York26-Nov-19 11:29 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Marc Clifton26-Nov-19 13:11
communityengineerMarc Clifton26-Nov-19 13:11 
GeneralRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Dan Neely27-Nov-19 4:22
MemberDan Neely27-Nov-19 4:22 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
GuyThiebaut26-Nov-19 21:47
professionalGuyThiebaut26-Nov-19 21:47 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
RichardS26-Nov-19 22:02
MemberRichardS26-Nov-19 22:02 
Yes & No


We draw a distinction in style of testing, as in we would write tests in a integration style but not as far as a database. We have a common data access layer and mock out data returned with test data. Code above the data layer is all tested with concretes, so our tests do end with lots of data setup (but using Builders/Mothers/Factories we can enhance common data providers to many tests). The tests all run from the highest level possible and pass through all units - we have abstracted away the http/message infrastructure so our starting units are after the "command" reaches the domain.

In the past we would test each unit individually then moved over to a more concrete implementation testing.

Our conclusion is:
1. We have far fewer tests to maintain

2. Our tests are more resilient to change - e.g. one dependency change/refactoring doesn't result in 45 tests needing to be changed, but just update in a common data change (our tests focus on behaviours being met) if the change has no material change to expected output.

3. We can test integration of units quicker - e.g. using strategy/command patterns and only testing units that are mocked has bitten us badly, so testing full concrete implementations ensured correctness.


Where we deviate from the above pattern is where our tests need to test multiple paths in a specific unit (i.e. when the result is null given 3 out 6 inputs, constructor testing, builder testing, etc.), the cost of testing this from the upper level would have infeasible. Then we hit that unit directly with tests.

With this approach we have seen our developers making better testing decisions and code evolving better as they are not swamped with updating tests just because they need to do a refactoring for new functionality.
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Tomas Takac26-Nov-19 22:26
MemberTomas Takac26-Nov-19 22:26 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Carl_Sharman26-Nov-19 22:41
MemberCarl_Sharman26-Nov-19 22:41 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Stuart Dootson26-Nov-19 23:58
professionalStuart Dootson26-Nov-19 23:58 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
#realJSOP27-Nov-19 2:11
mva#realJSOP27-Nov-19 2:11 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Ed K27-Nov-19 3:31
MemberEd K27-Nov-19 3:31 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
davecasdf27-Nov-19 5:36
Memberdavecasdf27-Nov-19 5:36 
GeneralRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
MSBassSinger27-Nov-19 7:42
professionalMSBassSinger27-Nov-19 7:42 
AnswerRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
Bruce Patin27-Nov-19 7:58
MemberBruce Patin27-Nov-19 7:58 
GeneralRe: Unit testing discussion - Mock Data - Yes, No, or Yes & No? Pin
MSBassSinger27-Nov-19 8:08
professionalMSBassSinger27-Nov-19 8:08 
GeneralThought of the Day Pin
OriginalGriff26-Nov-19 6:07
communityengineerOriginalGriff26-Nov-19 6:07 
GeneralRe: Thought of the Day Pin
DRHuff26-Nov-19 6:21
MemberDRHuff26-Nov-19 6:21 
GeneralRe: Thought of the Day Pin
Daniel Pfeffer26-Nov-19 6:40
professionalDaniel Pfeffer26-Nov-19 6:40 
GeneralRe: Thought of the Day Pin
W Balboos26-Nov-19 7:24
mveW Balboos26-Nov-19 7:24 
GeneralRe: Thought of the Day Pin
DRHuff26-Nov-19 10:08
MemberDRHuff26-Nov-19 10:08 
GeneralRe: Thought of the Day Pin
jeron126-Nov-19 7:59
Memberjeron126-Nov-19 7:59 
GeneralRe: Thought of the Day Pin
Kschuler26-Nov-19 9:20
MemberKschuler26-Nov-19 9:20 
GeneralRe: Thought of the Day Pin
Mike Hankey26-Nov-19 11:18
professionalMike Hankey26-Nov-19 11:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.