TDD going deep Day 2

by Lord Cod3n 19. September 2008 06:29

 First of, created the following test case...

        [TestMethod]
        public void canGetListofClassesFromCodeFile()
        {
            CodeManager cm = new CodeManager();
            string[] classnames = cm.GetClassNamesFromFile();
            Assert.IsTrue(classnames.Count() > 0);
        }

What I did here was write the test the way I wanted it to work.  This is a little difficult because design and implementation keep flying around in my head.  I suppressed the urge to design and possibly over-design and went with adding a user story/functionality to the code. 

The first time the test would not compile, so I implemented the GetClassNamesFromFile() with no code in the method.  The code compiles but throws a NotImplementedException.  We will return a List<string> with one element.  

The test case passed, and I am returned a List<string> instead, with a classname that I added. Once again I am faced with an incorrect implementation and I wonder do I add another test to fix it, or do I modify the code now. 

Q. What happens when one test breaks another test?

A.  [I have not been able to answer this.  Feel free to post an answer in the comments] 

Now attempting, to implement reading in the code file.  My unit test is failing, so I am incrementally fixing it.

My code feels very messy at the moment.  I will post up more later.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

William Moore is the lead Software Architect and Technologist for Coden Enterprises. He has more than a decade of software development experience primarily Microsoft Platforms.  William enjoys the full gamit of coding everything from the UI down to the database.

Most comments

Page List