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

  • Home
  • SEARCH
  • 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 9151705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:52:03+00:00 2026-06-17T11:52:03+00:00

I am new to the Unit Testing Framework. Using VS 2010, I use an

  • 0

I am new to the Unit Testing Framework. Using VS 2010, I use an XML as my datasource.

Suppose my XML would look like this:

<testgroup>
  <test>
    <param1>100</param1>
    <param2>200</param2>
  </test>
  <test>
    <param1>333</param1>
    <param2>222</param2>
  </test>
</testgroup>

So a test group could contain a lot of tests. It wouldn’t be efficient to break them out in individual xml files. For simplicity, pretend that param1 is an int and param2 is another int and my test would be to verify that param2 > param1.

Is it possible to write a single TestMethod so that it iterates through the various tests from the XML such that the Unit Test Framework will show a test for each?

I haven’t found a solution so far. Perhaps the datasource is not meant to be test data driven this way.

  • 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-06-17T11:52:04+00:00Added an answer on June 17, 2026 at 11:52 am

    Using NUnit, you can do the following:

    [TestMethod]
    public void TestDerpMethod(int a, string b, bool c)
    {
        //...test code...
    }
    

    You can do multiple test cases like so:

    [TestMethod]
    [TestCase(12, "12", true)]
    [TestCase(15, "15", false)]
    public void TestDerpMethod(int a, string b, bool c)
    {
        //...test code...
    }
    

    You can also use this method with XML using this method:

    <Rows>
        <Row>
            <A1>1</A1>
            <A2>1</A2>
            <Result>2</Result>
        </Row>
        <Row>
            <A1>1</A1>
            <A2>2</A2>
            <Result>3</Result>
        </Row>
        <Row>
            <A1>1</A1>
            <A2>-1</A2>
            <Result>1</Result>
        </Row>
    </Rows>
    

    and the C#:

    [TestMethod]
    [DeploymentItem("ProjectName\\SumTestData.xml")]
    [DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML",
                       "|DataDirectory|\\SumTestData.xml",
                       "Row",
                        DataAccessMethod.Sequential)]
    public void SumTest()
    {
        int a1 = Int32.Parse((string)TestContext.DataRow["A1"]);
        int a2 = Int32.Parse((string)TestContext.DataRow["A2"]);
        int result = Int32.Parse((string)TestContext.DataRow["Result"]);
        ExecSumTest(a1, a2, result);
    }
    
    
    private static void ExecSumTest(int a1, int a2, int result)
    {
        Assert.AreEqual(a1 + a2, result);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still new to Unit testing, and specifically PHPUnit as the testing framework. Suppose
I am new to unit testing, and would like to know how you would
I'm leaning toward using MSTest as unit testing framework for a new project but
I am using the Silverlight Unit Testing Framework to test some View Manager classes.
For my project I am using the integrated Visual Studio unit-testing framework but I
When I try using unit tests (Microsoft vs2010-embedded testing framework) with MVC3, all unit
I am using Rhino Mocks as a mocking framework for unit testing. I have
I'm using the Moq framework to do my unit testing. I'm following some really
My main JavaScript framework is jQuery , so I would like my unit test
I'm new with unit testing in visual studio and I want to load a

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.