Click here to Skip to main content
15,890,741 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.

 
GeneralRe: Sharepoint? Pin
Mark_Wallace24-Oct-16 10:35
Mark_Wallace24-Oct-16 10:35 
AnswerRe: Sharepoint? Pin
Michel Godfroid24-Oct-16 5:42
Michel Godfroid24-Oct-16 5:42 
AnswerRe: Sharepoint? Pin
rnbergren24-Oct-16 5:46
rnbergren24-Oct-16 5:46 
AnswerRe: Sharepoint? Pin
Idaho Edokpayi24-Oct-16 6:58
Idaho Edokpayi24-Oct-16 6:58 
AnswerRe: Sharepoint? Pin
Snorri Kristjansson24-Oct-16 7:00
professionalSnorri Kristjansson24-Oct-16 7:00 
AnswerRe: Sharepoint? Pin
Gerry Schmitz24-Oct-16 7:23
mveGerry Schmitz24-Oct-16 7:23 
AnswerRe: Sharepoint? Pin
Дмитрий Блинков25-Oct-16 20:57
Дмитрий Блинков25-Oct-16 20:57 
QuestionUnit Testing/TDD Help Pin
TheOnlyRealTodd21-Oct-16 12:42
professionalTheOnlyRealTodd21-Oct-16 12:42 
I'm just now trying to adopt my thinking to Test Driven Development mode and I'm finding strange, inconsistent, and bizarre things happening in my thought processes and code in some ways as well. Is this pretty normal when you first try to learn TDD?

For example, I find myself writing a lot of tests and then realizing afterwards "Hey, that could/should have been broken down into 2 separate unit tests" or maybe vice-versa.

I'm not really sure what/if there is a gold-standard on how much a unit test should be broken down. Another thing is sometimes I question whether I am wasting my time on a specific test. So for example, say I have some simple code like this:

C#
public class IntegerStats
    {
        public int MaxValue { get; private set; }
        public int MinValue { get; private set; }
        public int NumberOfElements { get; private set; }
        public double AverageValue { get; private set; }

        public IntegerStats(int[] inputArray)
        {
            MaxValue = inputArray.Max();
            MinValue = inputArray.Min();
            AverageValue = inputArray.Average();
            NumberOfElements = inputArray.Length;
        }
    }


My first two unit tests look like this:

C#
[Test]
        public void ProvideArrayReturnsIntStatsObject()
        {
            
            int[] testArray = {1, 5, 254783, 98, 4793, 67};
            IntegerStats intStats = new IntegerStats(testArray);

            Assert.IsTrue(intStats.GetType().ToString().Contains("IntegerStats"));

        }

        [Test]
        public void Length5ArrayLengthIs5()
        {
            var result = new IntegerStats(new int[]{5,4,8,9,4});

            Assert.AreEqual(result.NumberOfElements,5);
        }


However, should I be passing multiple arrays in to this one test or should I make several array length tests of different lengths? How do I know if the method is adequately tested?

My next plans were to continue testing the other properties... But then I was questioning whether I should even be testing these methods since they are using built-in provided standard library algorithms rather than my own custom algorithms in the first place.

Also, I had first started out with a test checking whether all of the stats were accurate in one big test but then I realized that's not really a unit test since it could/should have been broken down more.

Any advice/resources on this would be super helpful. The thing is, I've done plenty of reading about "What unit testing is" but putting it into practice for me has been quite different.
AnswerRe: Unit Testing/TDD Help Pin
Eddy Vluggen21-Oct-16 13:02
professionalEddy Vluggen21-Oct-16 13:02 
AnswerRe: Unit Testing/TDD Help Pin
Marc Clifton21-Oct-16 14:31
mvaMarc Clifton21-Oct-16 14:31 
GeneralRe: Unit Testing/TDD Help Pin
Mark_Wallace21-Oct-16 21:02
Mark_Wallace21-Oct-16 21:02 
GeneralRe: Unit Testing/TDD Help Pin
Marc Clifton22-Oct-16 3:49
mvaMarc Clifton22-Oct-16 3:49 
AnswerRe: Unit Testing/TDD Help Pin
Sander Rossel22-Oct-16 2:01
professionalSander Rossel22-Oct-16 2:01 
AnswerRe: Unit Testing/TDD Help Pin
AndrewDavie24-Oct-16 5:01
AndrewDavie24-Oct-16 5:01 
GeneralWas Checking Out Github: Then It Was gone - DDoS Pin
raddevus21-Oct-16 9:59
mvaraddevus21-Oct-16 9:59 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Vincent Maverick Durano21-Oct-16 10:05
professionalVincent Maverick Durano21-Oct-16 10:05 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Mark_Wallace21-Oct-16 10:16
Mark_Wallace21-Oct-16 10:16 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Afzaal Ahmad Zeeshan21-Oct-16 10:21
professionalAfzaal Ahmad Zeeshan21-Oct-16 10:21 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Mark_Wallace21-Oct-16 11:13
Mark_Wallace21-Oct-16 11:13 
JokeRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Afzaal Ahmad Zeeshan21-Oct-16 11:14
professionalAfzaal Ahmad Zeeshan21-Oct-16 11:14 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Mark_Wallace21-Oct-16 11:28
Mark_Wallace21-Oct-16 11:28 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
raddevus21-Oct-16 10:33
mvaraddevus21-Oct-16 10:33 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Vincent Maverick Durano21-Oct-16 10:35
professionalVincent Maverick Durano21-Oct-16 10:35 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Afzaal Ahmad Zeeshan21-Oct-16 10:20
professionalAfzaal Ahmad Zeeshan21-Oct-16 10:20 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Ryan Peden21-Oct-16 10:27
professionalRyan Peden21-Oct-16 10:27 

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.