Questions tagged [parameterized-unit-test]

Parameterized unit tests is a feature of some unit testing frameworks. It supports executing a given unit test multiple times with different arguments.

116 questions
15
votes
2 answers

Is there a way to pass delegates to a NUnit TestCase or TestFixture?

Basically I want to be able to plug-in methods to a TestCase or TestFixture in NUnit to vary the behavior. In essence I want to do this: [TestFixture] public class MethodTests { public delegate void SimpleDelegate(); public static void…
Bryan Mau
  • 155
  • 1
  • 6
13
votes
2 answers

Count subtests in Python unittests separately

Since version 3.4, Python supports a simple subtest syntax when writing unittests. A simple example could look like this: import unittest class NumbersTest(unittest.TestCase): def test_successful(self): """A test with subtests that…
Dirk
  • 9,381
  • 17
  • 70
  • 98
12
votes
1 answer

Parameterize both class and tests in JUnit 5

Is there a way to parameterize both test class (like you could do with Parameterized and @Parameters in JUnit 4) and test methods (like you could do with JUnitParams in JUnit 4 or with @ParameterizedTest in JUnit 5)? I need to get the Cartesian…
Sergei Tachenov
  • 24,345
  • 8
  • 57
  • 73
9
votes
5 answers

ParameterizedTest with a name in Eclipse Testrunner

When you run a JUnit 4 ParameterizedTest with the Eclipse TestRunner, the graphical representation is rather dumb: for each test you have a node called [0], [1], etc. Is it possible give the tests [0], [1], etc. explicit names? Implementing a…
Dr. Hans-Peter Störr
  • 25,298
  • 30
  • 102
  • 139
8
votes
3 answers

Parameterized Unit Tests with Visual Studio 2015 Intellitest

One feature I've wanted to see in MSTest for a long time has been Parameterized Unit Tests (PUTs). I was excited to hear that Intellitest would be capable of creating said tests. I've started playing with Intellitest, however, and I'm thinking my…
7
votes
1 answer

JUnit5 multiple sources for different arguments (cartesian product)

I am trying to write a test with JUnit 5 which should test multiple combinations of some parameters. Essentially I want to test some cartesian product of inputs from different sources. Consider the following test: import static…
Madjosz
  • 509
  • 1
  • 5
  • 13
7
votes
2 answers

Boost Test: How to write parameterized test cases

I've got a boost test case. Most lines of this test case are executed regardless of the parameters. But there are parts which are executed based on the provided parameter. I want to avoid writing two separate test cases which are almost identical…
B Faley
  • 17,120
  • 43
  • 133
  • 223
6
votes
3 answers

@ParameterizedTest can't be resolved in IntelliJ IDEA 2017.3

I'm new to JUnit testing and I would like to create a parameterized test in IntelliJ IDEA 2017.3.3. So I added JUnit 5: Then IntelliJ downloaded org.junit.jupiter:junit-jupiter-api:5.0.0. Now, @Test is working, but @ParameterizedTest is not. It…
Aloso
  • 5,123
  • 4
  • 24
  • 41
6
votes
3 answers

Python Testing how to run parameterised Testcases and pass a parameter to setupClass

I have an python unitest. In the setupClass method I so some timeconsuming tasks... The tests itself run very fast. Now i would like to run the same Testcase with multiple sets of parameters. How can I achieve this? I ve tried differet approaches…
6
votes
2 answers

JUnitParams not working with String array

Consider this test class, working with JUnit 4 and JUnitParams: import static junitparams.JUnitParamsRunner.$; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Test; import…
Juergen
  • 3,489
  • 6
  • 35
  • 59
6
votes
2 answers

What kind of test cases can we write using DUnit?

I am using Delphi 7. I am new to DUnit, my doubt is what kind of test cases I can write using DUnit and how (that is very important for me). Is it possible to write test cases for a particular button click event? Because in that event there may be a…
5
votes
0 answers

Subtest like feature in python 2.7?

How can I write test cases like below in Python 2.7? I don't have an option of using Pytest/Python3. import unittest class TestStringMethods(unittest.TestCase): def test_upper(self): tests = [ ('foo', 'FOO'), …
ThinkGeek
  • 4,749
  • 13
  • 44
  • 91
5
votes
0 answers

Unable to force newer version of surefire-plugin in Maven

I have a maven project and I am using the surefire-plugin to run my tests. Previously, I didn't force any version and maven picked up the 2.4.3 for me (why ??). I want to use 2.7.2 instead, which has better support for JUnit4 (especially…
Raphael Jolivet
  • 3,940
  • 5
  • 36
  • 56
5
votes
2 answers

Unable to get Default Constructor for class in Unit Test Project

I have created a unit test project. I get an exception specifying Unable to get default constructor for class *****.Tests.Controllers.PersonRegistration namespace *****.Tests.Controllers { [TestClass] public class PersonRegistration { …
Harsha W
  • 3,162
  • 5
  • 43
  • 77
5
votes
2 answers

Is there an easier way to handle unit testing a method with too many conditions?

I have a method which has a lot of conditions in it: public bool IsLegalSomething(Order order) { var item0 = order.Items.SingleOrDefault(x => x.ItemCode == "ItemCode0"); var item1 = order.Items.SingleOrDefault(x => x.ItemCode ==…
michael
  • 14,844
  • 28
  • 89
  • 177