I am using TestCaseSource on NUnit 2.6.1 to test the same Asserts with different object class constructor parameters.
I mean,
[Test, TestCaseSource("myConstructorsForMale")}
public void CheckMale(Person p) 
{
     Assert.That(p.IsMale);
}
static Person[] myConstructorsForMale = 
                     {
                         new Person("John"),
                         new Person(isMale=true),
                         new Person("Doe")
                     };
Ok, all is runing fine, but this is the result I received on the NUnit Console:
- CheckMale
 
- CheckMale(Person)
 - CheckMale(Person)
 - CheckMale(Person)
 
So I don't know what is the test executed on every iteration and if any of them fail I cannot get what is the failing test.
My question is: Are there any way to identify with a comment or something similar what is the parameter being passed to the test ? (in TestCaseSource Attribute way of do)
Thanks.
C is a structured, procedural programming language that has been widely used both for operating systems and applications and that has had a wide following in the academic community. Many versions of UNIX-based operating systems are written in C.
C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.
The C programming language is the recommended language for creating embedded system drivers and applications. The availability of machine-level hardware APIs, as well as the presence of C compilers, dynamic memory allocation, and deterministic resource consumption, make this language the most popular.
C is called middle-level language because it actually binds the gap between a machine level language and high-level languages. A user can use c language to do System Programming (for writing operating systems) as well as Application Programming (for generating menu driven customer billing systems).
If case of using 'native' NUnitor ReSharper as a test runner you can override ToString method so that you have good Person definitions. 
For example, your testing code could look like:
public class PersonTests
{
    [Test, TestCaseSource("myConstructorsForMale")]
    public void CheckMale(Person p)
    {
        Assert.That(p.IsMale);
    }
    static Person[] myConstructorsForMale = 
                 {
                     new Person("John"),
                     new Person{IsMale=true},
                     new Person("Doe")
                 };
}
Person class could be like:
public class Person
{
    public Person(string name)
    {
        this.Name = name;
    }
    public Person() { }
    public string Name { get; set; }
    public bool IsMale { get; set; }
    public override string ToString()
    {
        return string.Format("Name:{0};IsMale:{1}", Name, IsMale);
    }
}
The result window will look like this:

I also checked it on native NUnit test runner, which you probably use. It also displays Persons nicely:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With