Questions tagged [testcaseattribute]

Starting with 2.5.x, TestCaseAttributes can be used to create parametrized tests in NUnit.

Starting with 2.5.x, TestCaseAttributes can be used to create parametrized tests in NUnit. Order of parameters passed to the attribute should match the order of parameters to test method. Types should match. There is no implied conversion. This means that you should pass 1.0f instead of 1 if a float is expected as a method argument. TestAttribute is not required if TestCaseAttribute is specified.

7 questions
26
votes
6 answers

Is there a JUnit equivalent to NUnit's testcase attribute?

I've googled for JUnit test case, and it comes up with something that looks a lot more complicated to implement - where you have to create a new class that extends test case which you then call: public class MathTest extends TestCase { protected…
Steph
  • 261
  • 3
  • 3
13
votes
1 answer

NUnit and TestCaseAttribute, cross-join of parameters possible?

I have a unit-test that tests a variety of cases, like this: public void Test1(Int32 a, Int32 b, Int32 c) Let's say I want to create test-code without a loop, so I want to use TestCase to specify parameters like this: [TestCase(1, 1, 1)] public…
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
11
votes
2 answers

Using the 'TestCase' attribute with a two-dimensional array

I'm using NUnit and trying to implement tests for the following method: It should accept two integers and returns two dimensional array. So, header of my test looks like: [TestCase(5, 1, new int[,]{{1}, {2}, {3}, {4}, {5}})] public void…
mnlaptev
  • 113
  • 1
  • 6
6
votes
2 answers

NUnit TestCaseSource pass value to factory

I'm using the NUnit 2.5.3 TestCaseSource attribute and creating a factory to generate my tests. Something like this: [Test, TestCaseSource(typeof(TestCaseFactories), "VariableString")] public void Does_Pass_Standard_Description_Tests(string text) { …
Graham
  • 413
  • 3
  • 6
  • 10
2
votes
1 answer

How to get TestCategory for a Testcase using C#, Visual Studio MS Test

I am looking to find Test Category of a testcase at runtime using c#. I am using MSTEST, TestContext does not have any information related to TestCategory, I want to capture/log TestCategory information. In my case I have multiple TestCATEGORIES…
msbyuva
  • 3,467
  • 13
  • 63
  • 87
2
votes
1 answer

Improving test syntax for immensely many test cases

I've got me a test method and a bunch of test cases as follows. [TestCase(1, 2)] [TestCase(3, 4)] [TestCase(5, 6)] public void Smack(int a, int b) { ... } I've hidden the bunch of cases in a region but it doesn't feel right. I've tried with the…
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
0
votes
1 answer

nUnit - Ignoring a single inline TestCase

I'm using nUnit for some testing and I have a test with multiple inline test case inputs. I have a known bug with one of the TestCase inputs, and I would like to have that single TestCase ignored, but the other four run. When I…
klreeher
  • 1,391
  • 2
  • 15
  • 27