Click here to Skip to main content
15,886,788 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: I'm fairly old fashioned at times ... but should I embrace unit testing? Pin
Bruce Greene28-Jan-22 5:39
Bruce Greene28-Jan-22 5:39 
GeneralRe: I'm fairly old fashioned at times ... but should I embrace unit testing? Pin
Matt McGuire28-Jan-22 6:14
professionalMatt McGuire28-Jan-22 6:14 
AnswerRe: I'm fairly old fashioned at times ... but should I embrace unit testing? Pin
SeattleC++28-Jan-22 5:44
SeattleC++28-Jan-22 5:44 
AnswerRe: I'm fairly old fashioned at times ... but should I embrace unit testing? Pin
Matt McGuire28-Jan-22 6:04
professionalMatt McGuire28-Jan-22 6:04 
AnswerRe: I'm fairly old fashioned at times ... but should I embrace unit testing? Pin
CosmoSpacely28-Jan-22 6:04
CosmoSpacely28-Jan-22 6:04 
AnswerRe: I'm fairly old fashioned at times ... but should I embrace unit testing? Pin
Steve Naidamast28-Jan-22 7:09
professionalSteve Naidamast28-Jan-22 7:09 
AnswerRe: I'm fairly old fashioned at times ... but should I embrace unit testing? Pin
Shmoken9928-Jan-22 11:50
Shmoken9928-Jan-22 11:50 
AnswerRe: I'm fairly old fashioned at times ... but should I embrace unit testing? Pin
englebart5-Feb-22 5:36
professionalenglebart5-Feb-22 5:36 
Agree with r_hyde post and others that this is unit testing.

If you break each test into a separate, well-named method and add the right annotations in the right project type then it will be “testing framework ready” . It would eliminate your counter necessity and replace it with the method name.

Is it worth it? Not until you need to make another major enhancement on the subject class. Unless you want to do it as a learning exercise.

Before you start work on your next enhancement, clone your test class and refactor into a unit test.

Both tests should pass.

In the new unit test write the new tests for your enhancement. Run the tests and the new ones would fail until you implement the upgrades.

Depending on which version of IDE you have, you can use the unit tests to verify 100% code coverage in the subject. This is very powerful and has helped me in the past with a utility class similar to your range class.

I had written code for a range like [3,1] that treats it like [1,3] but did not have test cases for it. The coverage report caught my miss.

GeneralWhat are you listening to? Pin
Cpichols27-Jan-22 2:43
Cpichols27-Jan-22 2:43 
GeneralRe: What are you listening to? PinPopular
OriginalGriff27-Jan-22 2:45
mveOriginalGriff27-Jan-22 2:45 
GeneralRe: What are you listening to? Pin
Cpichols27-Jan-22 2:49
Cpichols27-Jan-22 2:49 
JokeRe: What are you listening to? Pin
musefan27-Jan-22 4:11
musefan27-Jan-22 4:11 
GeneralRe: What are you listening to? Pin
OriginalGriff27-Jan-22 4:27
mveOriginalGriff27-Jan-22 4:27 
GeneralRe: What are you listening to? Pin
dandy7227-Jan-22 5:48
dandy7227-Jan-22 5:48 
GeneralRe: What are you listening to? Pin
OriginalGriff27-Jan-22 6:15
mveOriginalGriff27-Jan-22 6:15 
GeneralRe: What are you listening to? Pin
RickZeeland27-Jan-22 6:17
mveRickZeeland27-Jan-22 6:17 
GeneralRe: What are you listening to? Pin
jmaida28-Jan-22 16:54
jmaida28-Jan-22 16:54 
GeneralRe: What are you listening to? Pin
Maximilien27-Jan-22 2:55
Maximilien27-Jan-22 2:55 
GeneralRe: What are you listening to? Pin
Cpichols27-Jan-22 3:38
Cpichols27-Jan-22 3:38 
GeneralRe: What are you listening to? Pin
Slacker00727-Jan-22 3:00
professionalSlacker00727-Jan-22 3:00 
GeneralRe: What are you listening to? Pin
Cpichols27-Jan-22 3:37
Cpichols27-Jan-22 3:37 
GeneralRe: What are you listening to? Pin
Eddy Vluggen27-Jan-22 3:08
professionalEddy Vluggen27-Jan-22 3:08 
GeneralRe: What are you listening to? Pin
Cpichols27-Jan-22 3:36
Cpichols27-Jan-22 3:36 
GeneralRe: What are you listening to? Pin
snorkie27-Jan-22 3:19
professionalsnorkie27-Jan-22 3:19 
GeneralRe: What are you listening to? Pin
Cpichols27-Jan-22 3:38
Cpichols27-Jan-22 3:38 

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.