Two different styles of testing a custom JSON schema generator











up vote
3
down vote

favorite
1












I'm a junior programmer, and I've only been in the industry a couple of months.



One of the aspects that I struggle with most is testing my code. I can write tests, and I can ensure that my code passes the tests successfully. However the issues I have relates to whether or not I am doing my testing correctly. At the moment my testing strategy seems to consist of checking that anything that can go wrong with my code doesn't actually go wrong. So I end up testing for many different eventualities e.g. input is valid, input is null, input is incorrect etc.



Today one of my mentors showed me his style of testing, which consists of BDD oriented testing. Although I can see where the advantages lies, I feel like that with his style of testing I am writing a lot more code to cover the same area.



Today I've written a number of tests in both my normal style and the BDD style. I'd really appreciate it if someone could have a look through two of my test classes and tell me which is the more effective testing style, and if I should ditch the way I usually test.



This code is testing a custom built JSON schema generator. First a JSON file is fed into the program and a JSON schema document is created. Below one of the classes that is used in the program SchemaDefinitionPropertyFactory is being tested to ensure correct functionality. For more information please see here: https://json-schema.org/understanding-json-schema/structuring.html



My style of testing:



        private Question _question;
private SchemaDefinitionPropertyFactory _factory;

[SetUp]
public void Setup()
{
_question = new Question
{
Id = 1,
Text = "Question 1",
Type = "text",
Required = "1",
Valid_answers = null,
Conditional_question_id = null,
Conditional_question_answered = null,
Fk_section_id = "1"
};

_factory = new SchemaDefinitionPropertyFactory();
}

[Test]
public void BuildPropertiesList_ValidQuestionInput_ReturnsCorrectListOfPropertyFieldsAndOnlyOneSchemaPropertyInList()
{
List<SchemaProperty> propertyList = _factory.BuildPropertiesList(_question);
List <SchemaPropertyField> propertyFields = propertyList[0].PropertyFields;

Assert.That(propertyFields.Count, Is.EqualTo(2));

Assert.That(propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(propertyFields[0].Value, Is.EqualTo("string"));

Assert.That(propertyFields[1].Name, Is.EqualTo("minLength"));
Assert.That(propertyFields[1].Value, Is.EqualTo("1"));

Assert.That(propertyList.Count, Is.EqualTo(1));
}

[Test]
public void BuildPropertiesList_NonRequiredQuestion_PropertyDoesNotHaveMinimumLength()
{
_question.Required = "0";

List<SchemaProperty> propertyList = _factory.BuildPropertiesList(_question);
List<SchemaPropertyField> propertyFields = propertyList[0].PropertyFields;

Assert.That(propertyFields.Count, Is.EqualTo(1));

Assert.That(propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(propertyFields[0].Value, Is.EqualTo("string"));

}


BDD Testing style



   private List<SchemaProperty> _propertyList;
private List<SchemaPropertyField> _propertyFields;
private Question _question;


protected override void GivenThat()
{
ClassUnderTest = new SchemaDefinitionPropertyFactory();

_question = new Question
{
Id = 1,
Text = "Question 1",
Type = "text",
Required = "1",
Valid_answers = null,
Conditional_question_id = null,
Conditional_question_answered = null,
Fk_section_id = "1"
};
}

protected override void When()
{
_propertyList = ClassUnderTest.BuildPropertiesList(_question);
_propertyFields = _propertyList[0].PropertyFields;
}

[Then]
public void ReturnsCorrectListOfPropertyFields()
{
Assert.That(_propertyFields.Count, Is.EqualTo(2));

Assert.That(_propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(_propertyFields[0].Value, Is.EqualTo("string"));

Assert.That(_propertyFields[1].Name, Is.EqualTo("minLength"));
Assert.That(_propertyFields[1].Value, Is.EqualTo("1"));
}

[Then]
public void ThereIsOnlyOneSchemaPropertyInList()
{
Assert.That(_propertyList.Count, Is.EqualTo(1));
}

[Then]
public void PropertyDoesNotHaveInvalidFields()
{
Assert.That(_propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(_propertyFields[0].Value, Is.EqualTo("string"));
}









share|improve this question









New contributor




Jake12342134 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    The first thing that you need to do on on Code Review is to explain what your code is doing so please edit your question and describe what you are testing. Then I think it should be fine. It'd be also beneficial for your question if you added the complete test-class and of course the code you are testing.
    – t3chb0t
    Nov 14 at 16:26

















up vote
3
down vote

favorite
1












I'm a junior programmer, and I've only been in the industry a couple of months.



One of the aspects that I struggle with most is testing my code. I can write tests, and I can ensure that my code passes the tests successfully. However the issues I have relates to whether or not I am doing my testing correctly. At the moment my testing strategy seems to consist of checking that anything that can go wrong with my code doesn't actually go wrong. So I end up testing for many different eventualities e.g. input is valid, input is null, input is incorrect etc.



Today one of my mentors showed me his style of testing, which consists of BDD oriented testing. Although I can see where the advantages lies, I feel like that with his style of testing I am writing a lot more code to cover the same area.



Today I've written a number of tests in both my normal style and the BDD style. I'd really appreciate it if someone could have a look through two of my test classes and tell me which is the more effective testing style, and if I should ditch the way I usually test.



This code is testing a custom built JSON schema generator. First a JSON file is fed into the program and a JSON schema document is created. Below one of the classes that is used in the program SchemaDefinitionPropertyFactory is being tested to ensure correct functionality. For more information please see here: https://json-schema.org/understanding-json-schema/structuring.html



My style of testing:



        private Question _question;
private SchemaDefinitionPropertyFactory _factory;

[SetUp]
public void Setup()
{
_question = new Question
{
Id = 1,
Text = "Question 1",
Type = "text",
Required = "1",
Valid_answers = null,
Conditional_question_id = null,
Conditional_question_answered = null,
Fk_section_id = "1"
};

_factory = new SchemaDefinitionPropertyFactory();
}

[Test]
public void BuildPropertiesList_ValidQuestionInput_ReturnsCorrectListOfPropertyFieldsAndOnlyOneSchemaPropertyInList()
{
List<SchemaProperty> propertyList = _factory.BuildPropertiesList(_question);
List <SchemaPropertyField> propertyFields = propertyList[0].PropertyFields;

Assert.That(propertyFields.Count, Is.EqualTo(2));

Assert.That(propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(propertyFields[0].Value, Is.EqualTo("string"));

Assert.That(propertyFields[1].Name, Is.EqualTo("minLength"));
Assert.That(propertyFields[1].Value, Is.EqualTo("1"));

Assert.That(propertyList.Count, Is.EqualTo(1));
}

[Test]
public void BuildPropertiesList_NonRequiredQuestion_PropertyDoesNotHaveMinimumLength()
{
_question.Required = "0";

List<SchemaProperty> propertyList = _factory.BuildPropertiesList(_question);
List<SchemaPropertyField> propertyFields = propertyList[0].PropertyFields;

Assert.That(propertyFields.Count, Is.EqualTo(1));

Assert.That(propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(propertyFields[0].Value, Is.EqualTo("string"));

}


BDD Testing style



   private List<SchemaProperty> _propertyList;
private List<SchemaPropertyField> _propertyFields;
private Question _question;


protected override void GivenThat()
{
ClassUnderTest = new SchemaDefinitionPropertyFactory();

_question = new Question
{
Id = 1,
Text = "Question 1",
Type = "text",
Required = "1",
Valid_answers = null,
Conditional_question_id = null,
Conditional_question_answered = null,
Fk_section_id = "1"
};
}

protected override void When()
{
_propertyList = ClassUnderTest.BuildPropertiesList(_question);
_propertyFields = _propertyList[0].PropertyFields;
}

[Then]
public void ReturnsCorrectListOfPropertyFields()
{
Assert.That(_propertyFields.Count, Is.EqualTo(2));

Assert.That(_propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(_propertyFields[0].Value, Is.EqualTo("string"));

Assert.That(_propertyFields[1].Name, Is.EqualTo("minLength"));
Assert.That(_propertyFields[1].Value, Is.EqualTo("1"));
}

[Then]
public void ThereIsOnlyOneSchemaPropertyInList()
{
Assert.That(_propertyList.Count, Is.EqualTo(1));
}

[Then]
public void PropertyDoesNotHaveInvalidFields()
{
Assert.That(_propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(_propertyFields[0].Value, Is.EqualTo("string"));
}









share|improve this question









New contributor




Jake12342134 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    The first thing that you need to do on on Code Review is to explain what your code is doing so please edit your question and describe what you are testing. Then I think it should be fine. It'd be also beneficial for your question if you added the complete test-class and of course the code you are testing.
    – t3chb0t
    Nov 14 at 16:26















up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





I'm a junior programmer, and I've only been in the industry a couple of months.



One of the aspects that I struggle with most is testing my code. I can write tests, and I can ensure that my code passes the tests successfully. However the issues I have relates to whether or not I am doing my testing correctly. At the moment my testing strategy seems to consist of checking that anything that can go wrong with my code doesn't actually go wrong. So I end up testing for many different eventualities e.g. input is valid, input is null, input is incorrect etc.



Today one of my mentors showed me his style of testing, which consists of BDD oriented testing. Although I can see where the advantages lies, I feel like that with his style of testing I am writing a lot more code to cover the same area.



Today I've written a number of tests in both my normal style and the BDD style. I'd really appreciate it if someone could have a look through two of my test classes and tell me which is the more effective testing style, and if I should ditch the way I usually test.



This code is testing a custom built JSON schema generator. First a JSON file is fed into the program and a JSON schema document is created. Below one of the classes that is used in the program SchemaDefinitionPropertyFactory is being tested to ensure correct functionality. For more information please see here: https://json-schema.org/understanding-json-schema/structuring.html



My style of testing:



        private Question _question;
private SchemaDefinitionPropertyFactory _factory;

[SetUp]
public void Setup()
{
_question = new Question
{
Id = 1,
Text = "Question 1",
Type = "text",
Required = "1",
Valid_answers = null,
Conditional_question_id = null,
Conditional_question_answered = null,
Fk_section_id = "1"
};

_factory = new SchemaDefinitionPropertyFactory();
}

[Test]
public void BuildPropertiesList_ValidQuestionInput_ReturnsCorrectListOfPropertyFieldsAndOnlyOneSchemaPropertyInList()
{
List<SchemaProperty> propertyList = _factory.BuildPropertiesList(_question);
List <SchemaPropertyField> propertyFields = propertyList[0].PropertyFields;

Assert.That(propertyFields.Count, Is.EqualTo(2));

Assert.That(propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(propertyFields[0].Value, Is.EqualTo("string"));

Assert.That(propertyFields[1].Name, Is.EqualTo("minLength"));
Assert.That(propertyFields[1].Value, Is.EqualTo("1"));

Assert.That(propertyList.Count, Is.EqualTo(1));
}

[Test]
public void BuildPropertiesList_NonRequiredQuestion_PropertyDoesNotHaveMinimumLength()
{
_question.Required = "0";

List<SchemaProperty> propertyList = _factory.BuildPropertiesList(_question);
List<SchemaPropertyField> propertyFields = propertyList[0].PropertyFields;

Assert.That(propertyFields.Count, Is.EqualTo(1));

Assert.That(propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(propertyFields[0].Value, Is.EqualTo("string"));

}


BDD Testing style



   private List<SchemaProperty> _propertyList;
private List<SchemaPropertyField> _propertyFields;
private Question _question;


protected override void GivenThat()
{
ClassUnderTest = new SchemaDefinitionPropertyFactory();

_question = new Question
{
Id = 1,
Text = "Question 1",
Type = "text",
Required = "1",
Valid_answers = null,
Conditional_question_id = null,
Conditional_question_answered = null,
Fk_section_id = "1"
};
}

protected override void When()
{
_propertyList = ClassUnderTest.BuildPropertiesList(_question);
_propertyFields = _propertyList[0].PropertyFields;
}

[Then]
public void ReturnsCorrectListOfPropertyFields()
{
Assert.That(_propertyFields.Count, Is.EqualTo(2));

Assert.That(_propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(_propertyFields[0].Value, Is.EqualTo("string"));

Assert.That(_propertyFields[1].Name, Is.EqualTo("minLength"));
Assert.That(_propertyFields[1].Value, Is.EqualTo("1"));
}

[Then]
public void ThereIsOnlyOneSchemaPropertyInList()
{
Assert.That(_propertyList.Count, Is.EqualTo(1));
}

[Then]
public void PropertyDoesNotHaveInvalidFields()
{
Assert.That(_propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(_propertyFields[0].Value, Is.EqualTo("string"));
}









share|improve this question









New contributor




Jake12342134 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm a junior programmer, and I've only been in the industry a couple of months.



One of the aspects that I struggle with most is testing my code. I can write tests, and I can ensure that my code passes the tests successfully. However the issues I have relates to whether or not I am doing my testing correctly. At the moment my testing strategy seems to consist of checking that anything that can go wrong with my code doesn't actually go wrong. So I end up testing for many different eventualities e.g. input is valid, input is null, input is incorrect etc.



Today one of my mentors showed me his style of testing, which consists of BDD oriented testing. Although I can see where the advantages lies, I feel like that with his style of testing I am writing a lot more code to cover the same area.



Today I've written a number of tests in both my normal style and the BDD style. I'd really appreciate it if someone could have a look through two of my test classes and tell me which is the more effective testing style, and if I should ditch the way I usually test.



This code is testing a custom built JSON schema generator. First a JSON file is fed into the program and a JSON schema document is created. Below one of the classes that is used in the program SchemaDefinitionPropertyFactory is being tested to ensure correct functionality. For more information please see here: https://json-schema.org/understanding-json-schema/structuring.html



My style of testing:



        private Question _question;
private SchemaDefinitionPropertyFactory _factory;

[SetUp]
public void Setup()
{
_question = new Question
{
Id = 1,
Text = "Question 1",
Type = "text",
Required = "1",
Valid_answers = null,
Conditional_question_id = null,
Conditional_question_answered = null,
Fk_section_id = "1"
};

_factory = new SchemaDefinitionPropertyFactory();
}

[Test]
public void BuildPropertiesList_ValidQuestionInput_ReturnsCorrectListOfPropertyFieldsAndOnlyOneSchemaPropertyInList()
{
List<SchemaProperty> propertyList = _factory.BuildPropertiesList(_question);
List <SchemaPropertyField> propertyFields = propertyList[0].PropertyFields;

Assert.That(propertyFields.Count, Is.EqualTo(2));

Assert.That(propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(propertyFields[0].Value, Is.EqualTo("string"));

Assert.That(propertyFields[1].Name, Is.EqualTo("minLength"));
Assert.That(propertyFields[1].Value, Is.EqualTo("1"));

Assert.That(propertyList.Count, Is.EqualTo(1));
}

[Test]
public void BuildPropertiesList_NonRequiredQuestion_PropertyDoesNotHaveMinimumLength()
{
_question.Required = "0";

List<SchemaProperty> propertyList = _factory.BuildPropertiesList(_question);
List<SchemaPropertyField> propertyFields = propertyList[0].PropertyFields;

Assert.That(propertyFields.Count, Is.EqualTo(1));

Assert.That(propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(propertyFields[0].Value, Is.EqualTo("string"));

}


BDD Testing style



   private List<SchemaProperty> _propertyList;
private List<SchemaPropertyField> _propertyFields;
private Question _question;


protected override void GivenThat()
{
ClassUnderTest = new SchemaDefinitionPropertyFactory();

_question = new Question
{
Id = 1,
Text = "Question 1",
Type = "text",
Required = "1",
Valid_answers = null,
Conditional_question_id = null,
Conditional_question_answered = null,
Fk_section_id = "1"
};
}

protected override void When()
{
_propertyList = ClassUnderTest.BuildPropertiesList(_question);
_propertyFields = _propertyList[0].PropertyFields;
}

[Then]
public void ReturnsCorrectListOfPropertyFields()
{
Assert.That(_propertyFields.Count, Is.EqualTo(2));

Assert.That(_propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(_propertyFields[0].Value, Is.EqualTo("string"));

Assert.That(_propertyFields[1].Name, Is.EqualTo("minLength"));
Assert.That(_propertyFields[1].Value, Is.EqualTo("1"));
}

[Then]
public void ThereIsOnlyOneSchemaPropertyInList()
{
Assert.That(_propertyList.Count, Is.EqualTo(1));
}

[Then]
public void PropertyDoesNotHaveInvalidFields()
{
Assert.That(_propertyFields[0].Name, Is.EqualTo("type"));
Assert.That(_propertyFields[0].Value, Is.EqualTo("string"));
}






c# unit-testing comparative-review






share|improve this question









New contributor




Jake12342134 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Jake12342134 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 14 at 16:31









t3chb0t

33.6k744108




33.6k744108






New contributor




Jake12342134 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 14 at 16:08









Jake12342134

162




162




New contributor




Jake12342134 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Jake12342134 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Jake12342134 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    The first thing that you need to do on on Code Review is to explain what your code is doing so please edit your question and describe what you are testing. Then I think it should be fine. It'd be also beneficial for your question if you added the complete test-class and of course the code you are testing.
    – t3chb0t
    Nov 14 at 16:26
















  • 1




    The first thing that you need to do on on Code Review is to explain what your code is doing so please edit your question and describe what you are testing. Then I think it should be fine. It'd be also beneficial for your question if you added the complete test-class and of course the code you are testing.
    – t3chb0t
    Nov 14 at 16:26










1




1




The first thing that you need to do on on Code Review is to explain what your code is doing so please edit your question and describe what you are testing. Then I think it should be fine. It'd be also beneficial for your question if you added the complete test-class and of course the code you are testing.
– t3chb0t
Nov 14 at 16:26






The first thing that you need to do on on Code Review is to explain what your code is doing so please edit your question and describe what you are testing. Then I think it should be fine. It'd be also beneficial for your question if you added the complete test-class and of course the code you are testing.
– t3chb0t
Nov 14 at 16:26












1 Answer
1






active

oldest

votes

















up vote
1
down vote













Your style of testing



I myself was using your style for a long time... until after several weeks I couldn't make any sense of them anymore. They are testing something, yes, but what and why? Nobody could say that anymore and especially when I wanted to know whether I tested a particular feature there was no way I could tell that.



Your client/customer/someone will tell you that something doesn't work... but all you see are properties and methods... now try to connect this with the broken feature.



BDD style



(This is my favourite.)



The BDD style on the contrary clearly shows you what you are testing so even after a couple of weeks you'll still be able to understand them. You don't want to know the input data from the test name. You want to take a quick look at the list and be able to tell what your code is capabale of.



You don't what to know the APIs you are testing from the test name. This doesn't help. They might seem obvious now when everything is fresh but in a couple of weeks you'll forget the most of it (if you're working on several projects). The only thing you'll be able to identify are the features and if you cannot find them quickly, you'll end up debugging your code and studying it from the beginning. This is a pain...






share|improve this answer





















    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "196"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Jake12342134 is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207663%2ftwo-different-styles-of-testing-a-custom-json-schema-generator%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Your style of testing



    I myself was using your style for a long time... until after several weeks I couldn't make any sense of them anymore. They are testing something, yes, but what and why? Nobody could say that anymore and especially when I wanted to know whether I tested a particular feature there was no way I could tell that.



    Your client/customer/someone will tell you that something doesn't work... but all you see are properties and methods... now try to connect this with the broken feature.



    BDD style



    (This is my favourite.)



    The BDD style on the contrary clearly shows you what you are testing so even after a couple of weeks you'll still be able to understand them. You don't want to know the input data from the test name. You want to take a quick look at the list and be able to tell what your code is capabale of.



    You don't what to know the APIs you are testing from the test name. This doesn't help. They might seem obvious now when everything is fresh but in a couple of weeks you'll forget the most of it (if you're working on several projects). The only thing you'll be able to identify are the features and if you cannot find them quickly, you'll end up debugging your code and studying it from the beginning. This is a pain...






    share|improve this answer

























      up vote
      1
      down vote













      Your style of testing



      I myself was using your style for a long time... until after several weeks I couldn't make any sense of them anymore. They are testing something, yes, but what and why? Nobody could say that anymore and especially when I wanted to know whether I tested a particular feature there was no way I could tell that.



      Your client/customer/someone will tell you that something doesn't work... but all you see are properties and methods... now try to connect this with the broken feature.



      BDD style



      (This is my favourite.)



      The BDD style on the contrary clearly shows you what you are testing so even after a couple of weeks you'll still be able to understand them. You don't want to know the input data from the test name. You want to take a quick look at the list and be able to tell what your code is capabale of.



      You don't what to know the APIs you are testing from the test name. This doesn't help. They might seem obvious now when everything is fresh but in a couple of weeks you'll forget the most of it (if you're working on several projects). The only thing you'll be able to identify are the features and if you cannot find them quickly, you'll end up debugging your code and studying it from the beginning. This is a pain...






      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        Your style of testing



        I myself was using your style for a long time... until after several weeks I couldn't make any sense of them anymore. They are testing something, yes, but what and why? Nobody could say that anymore and especially when I wanted to know whether I tested a particular feature there was no way I could tell that.



        Your client/customer/someone will tell you that something doesn't work... but all you see are properties and methods... now try to connect this with the broken feature.



        BDD style



        (This is my favourite.)



        The BDD style on the contrary clearly shows you what you are testing so even after a couple of weeks you'll still be able to understand them. You don't want to know the input data from the test name. You want to take a quick look at the list and be able to tell what your code is capabale of.



        You don't what to know the APIs you are testing from the test name. This doesn't help. They might seem obvious now when everything is fresh but in a couple of weeks you'll forget the most of it (if you're working on several projects). The only thing you'll be able to identify are the features and if you cannot find them quickly, you'll end up debugging your code and studying it from the beginning. This is a pain...






        share|improve this answer












        Your style of testing



        I myself was using your style for a long time... until after several weeks I couldn't make any sense of them anymore. They are testing something, yes, but what and why? Nobody could say that anymore and especially when I wanted to know whether I tested a particular feature there was no way I could tell that.



        Your client/customer/someone will tell you that something doesn't work... but all you see are properties and methods... now try to connect this with the broken feature.



        BDD style



        (This is my favourite.)



        The BDD style on the contrary clearly shows you what you are testing so even after a couple of weeks you'll still be able to understand them. You don't want to know the input data from the test name. You want to take a quick look at the list and be able to tell what your code is capabale of.



        You don't what to know the APIs you are testing from the test name. This doesn't help. They might seem obvious now when everything is fresh but in a couple of weeks you'll forget the most of it (if you're working on several projects). The only thing you'll be able to identify are the features and if you cannot find them quickly, you'll end up debugging your code and studying it from the beginning. This is a pain...







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 at 16:56









        t3chb0t

        33.6k744108




        33.6k744108






















            Jake12342134 is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            Jake12342134 is a new contributor. Be nice, and check out our Code of Conduct.













            Jake12342134 is a new contributor. Be nice, and check out our Code of Conduct.












            Jake12342134 is a new contributor. Be nice, and check out our Code of Conduct.















             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207663%2ftwo-different-styles-of-testing-a-custom-json-schema-generator%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Quarter-circle Tiles

            build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

            Mont Emei