Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:22:11+00:00 2026-05-31T05:22:11+00:00

Started learning TDD and met some misunderstandings about different approaches for writing tests. In

  • 0

Started learning TDD and met some misunderstandings about different approaches for writing tests.

In some articles it is said that you should write new test for every case. So, there can be two or more tests for a single method.

Another approach that I saw, is about writing more complex tests in several steps. For example: write test -> fail -> write code -> success -> modify current test (add new assertions) -> fail -> write code -> success -> and so on. After this steps done test is covering a whole logic of a single method.

What are pros and cons of that approaches of using TDD?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:22:12+00:00Added an answer on May 31, 2026 at 5:22 am

    It is “easier” to just add a bunch of assertions to an existing test case because you don’t need to create new test cases (and come up with names for them), but I would prefer to write smaller tests that are more specific. The main advantage is that you will have better information if/when a test fails about what went wrong.

    Let’s see if I can come up with a contrived example:

    [Fact]
    public void TestEverything()
    {
        var foo = new Foo();
        Assert.Equal(42, foo.TheAnswer);
        Assert.Equal(string.Empty, foo.Log);
        foo.DoSomething();
        Assert.Equal("something was done", foo.Log);
    }
    
    
    [Fact]
    public void TheAnswer_AfterCreation_ShouldAdhereToTheHitchhikersGuide()
    {
        var foo = new Foo();
        Assert.Equal(42, foo.TheAnswer);
    }
    
    [Fact]
    public void Log_AfterCreation_ShouldBeEmpty()
    {
        var foo = new Foo();
        Assert.Equal(string.Empty, foo.Log);
    }
    
    [Fact]
    public void Log_DoSomething_ShouldLogSomething()
    {
        var foo = new Foo();
        foo.DoSomething();
        Assert.Equal("something was done", foo.Log);
    }
    

    As you can see, inventing good names for test methods is really hard (and I did a bad job especially for the last one), but just imaging what happens if TheAnswer_AfterCreation_ShouldAdhereToTheHitchhikersGuide fails: you will get a pretty nice description from your test harness instead of the information that TestEverything has failed (Challenge: try to come up with a better name for it 😉 )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to embrace TDD and started learning about mocking. I need some
I'm just getting started with learning about Unit testing (and TDD in general). My
I started learning LISP and I heard that there is some kind of a
I started learning about lua language to develop games,i percept that most people uses
I recently started learning Emacs . I went through the tutorial, read some introductory
I have just started learning Erlang and am trying out some Project Euler problems
I started learning Iphone development. As i'm reading about the cocoa development framework, few
Just started learning Scheme. I'm using Dr. Racket as my compiler/interpreter. I need some
I started learning functional programming (OCaml), but I don't understand one important topic about
Hi I have just started learning about xsd as I want to use it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.