Search The Blog
About this site

@RoyOsherove

Subscribe!

This site aims to connect all the dots of my online activities - from tools, books blogs and twitter accounts, to upcoming conferences, engagements and user group talks.

from 5whys.com
Twitter: @RoyOsherove
My Book: The Art of Unit Testing
Latest Posts
« Implementing Unit Test MetaData using XtUnit custom attributes | Main | ThreadTester with new Ability: StopWhenTrue() and thread polling »
Monday
Jun252007

Unit Test Tip: Encode test data as part of your test xml comments

What a cool idea, and simple too.

You can encode various test data as XML comments on your test, and then use them in your test by parsing the XML file generated by the compiler. More details here.

Lars Thurop wrote the CommentReader which can enable a test that looks like this:

 

        /// <sample>
        ///        create table Orders ( id int, customer int );
        /// </sample>
        [Test]
        public void TestNonXmlComment()
        {
            string content = CommentReader.GetElement("sample");
            Assert.AreEqual(@"create table Orders ( id int, customer int );",
                              content.Trim());
        }

PrintView Printer Friendly Version

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>