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.

parameterized-unit-test
Filter by
Sorted by
Tagged with
1 vote
1 answer
386 views

How to parameterize xpath and parse it as a text?

I have a python file, Base.Py def provideElectricJobDetails(self): self.ui.driver.find_element_by_name("Title").send_keys("Test") self.ui.driver.find_element_by_xpath("//span[contains(...
Sidharth Gokul's user avatar
0 votes
1 answer
2k views

parameterizing pytest tests with fixtures and a command line argument

Trying to take a command line argument (table_name) into pytest (via conftest.py, see below) and use that argument in a helper method to make a query in a DB, and then use query results to create ...
potato_programmer's user avatar
12 votes
1 answer
6k views

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 @...
Sergei Tachenov's user avatar
-1 votes
2 answers
783 views

How to pass testCase value to next one with Pytest

import pytest def add(x): return x + 1 def sub(x): return x - 1 testData1 = [1, 2] testData2 = [3] class Test_math(object): @pytest.mark.parametrize('n', testData1) def test_add(...
Chweng Mega's user avatar
  • 1,648
2 votes
1 answer
668 views

Parameterized tests that use a custom test runner

We are using our custom test runner, that extend ParentRunner: public class OurTestRunner extends ParentRunner<TestRunnerForOneConfigCase> {...} class TestRunnerForOneConfigCase extends ...
Grzenio's user avatar
  • 36.3k
20 votes
6 answers
10k views

Parameterizing with array in Junit 5 (or other testing Java library) in smarter fashion

I'm trying to parameterize this test: @Test public void reverseQuote(double[] qsp) throws Exception { ...} It seems absurd to me that it doesn't exists some quick method to initialize array qsp like,...
Lore's user avatar
  • 1,516
0 votes
3 answers
546 views

Test with different parameters

I have following scenarios to Test. I would like to know which Testing framework will best fit to my requirement. Scenario 1) Param1, Param2, Param3, Param4, Param5 I will pass above parameters with ...
Ragini's user avatar
  • 1,519
6 votes
3 answers
8k views

@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 ...
Aloso's user avatar
  • 5,291
-1 votes
1 answer
579 views

JUnit 5 and multiple input data (Java)

How to use JUnit 5 to run series of tests of a computation, each for a different pair of input data and benchmark output? Condition: the computation should be performed only once per input and not ...
Mateusz's user avatar
  • 49
20 votes
3 answers
32k views

How to pass a list as a JUnit5's parameterized test parameter?

I want to parameterize my JUnit5 tests using three parameters: string, string and list<string>. No luck so far when using @CsvSource, which is the most convenient way of passing params for my ...
Grzegorz Piwowarek's user avatar
57 votes
4 answers
19k views

JUnit5 parameterized tests at class level

Is it possible to use JUnit5's parameterized new features to run test classes to receive test parameters instead of doing it at method level? With JUnit 4 a runner such as @RunWith(Parameterized::...
IS1_SO's user avatar
  • 935
4 votes
2 answers
3k views

Is there a way to create a custom parameters generator with googletest?

I am actually using googletest framework. I have a value parameterized test with std::tuple<int, double> This int represents the number of vertices in a regular polygon and the double ...
Jo Ham's user avatar
  • 149
14 votes
2 answers
4k views

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 ...
Dirk's user avatar
  • 9,751
6 votes
2 answers
14k views

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 { [...
Harsha W's user avatar
  • 3,276
1 vote
0 answers
399 views

JUnit Parameterized Tests Dynamic Loaded List

I have a list of products, each of which have its own list of catalogues. The available catalogues are not the same for every product. I´d love to parameterize this Suite, in a way that testing each ...
Enrique Castaneda's user avatar
6 votes
2 answers
2k views

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....
michael's user avatar
  • 15k
1 vote
0 answers
771 views

robolectric parameterized test - Array of PointF

Good day my fellow developers, I'm trying to write a Data Driven Unit test for my VectorHelper class. Since the class works heavily on PointF objects and those objects have no implementation in ...
Gregory Stein's user avatar
0 votes
1 answer
118 views

Using the output of a [ValueSourceAttribute] Nunit Test in the following Test

I am developing a unit test project where I create an item in a test, then create sub items for it in the following test. These tests are parameterized tests, and these parameters are collected in ...
user2739560's user avatar
54 votes
5 answers
23k views

jasmine parameterized unit test

Okay as a C# NUnit guy this might be odd. But does jasmine allow parameterized unit test? I am not sure if it goes against the "declare" and "it" to make things readable to non programmers. I have ...
Ashley Kilgour's user avatar
0 votes
1 answer
730 views

Apply different decorators based on a condition

I'm using unittest and nose-parametarized, and want to apply different decorators to a test based on a condition. I have a test and I want to skip unittest.skip the test or execute it @parameterized....
Mahyar's user avatar
  • 1,091
0 votes
1 answer
448 views

IllegalArgumentException in parameterized test class

I have a parametric test class, and I have a test method which I am expected to return IllegalArgumentException. @RunWith(value = Parameterized.class) public class TriangleParametrizedTest { @...
Azin 's user avatar
  • 21
4 votes
1 answer
4k views

Use Values- and Range-Attribute in NUnit TestFixture constructor

I have multiple test methods which should test all possible combinations of multiple parameters. I can use the NUnit ValueAttribute or RangeAttribute on methods like this: [TestFixture] public class ...
Xarbrough's user avatar
  • 1,411
1 vote
1 answer
479 views

how to get flexible columns with junitparams

I have this situation where I'm reading values from input file using junitparams. In some cases, my rows have values in all the columns (say 5), however, in other cases only the first few columns have ...
Hemant's user avatar
  • 1,333
6 votes
3 answers
11k views

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 ...
renzop's user avatar
  • 1,226
3 votes
1 answer
805 views

How to generate method parameters based on class parameters for Matlab unit tests

A program I am working on performs calculations that involve objects that can only have several possible sets of values. These parameter sets are read from a catalogue file. As an example say the ...
Tim's user avatar
  • 1,460
2 votes
2 answers
2k views

Nested tests in TestNG

In TestNG I have a parameterized Test A which automatically creates n tests from a dataProvider, and a Test B which should be executed each time a test in A finishes as I want to take advantage of the ...
Nana89's user avatar
  • 432
22 votes
8 answers
12k views

Parametrized unit tests in Swift

Is there any way to use parameterized unit tests, similar to what you can achieve in .Net using NUnit framework. [TestCase(12, 3, 4)] [TestCase(12, 2, 6)] [TestCase(12, 4, 3)] public void DivideTest(...
Maciej Jastrzebski's user avatar
49 votes
2 answers
27k views

indirect=True vs indirect=False in @pytest.mark.parametrize()?

I just want to understand what it means or what happens if I set indirect parameter to True or False in the pytest.mark.parametrize?
Froodo's user avatar
  • 603
5 votes
1 answer
574 views

Creating parametrized Matlab unittest with complicated properties

I'm trying to create a parametrized Matlab unittest where the TestParameter properties are generated "dynamically" by some code (e.g., with a for loop). As a simplified example, suppose my code is ...
Frank Meulenaar's user avatar
2 votes
2 answers
2k views

How to access class property in decorator in Python?

I am trying to use a nose_parameterized test and want to use it for a unittest method. from nose.tools import assert_equal from nose_parameterized import parameterized import unittest Class TestFoo(...
Mahsa Mortazavi's user avatar
1 vote
1 answer
370 views

Junit runs all Test with the parameter marked with @Parameter

In the following code, I would like to run TestMethod1 with the parameters marked with @Parameters @RunWith(Parameterized.class) public class Foo{ private boolean input; private boolean expected;...
Ronald's user avatar
  • 2,831
3 votes
3 answers
2k views

Test different methods with different subset of data in JUnit test case

Say I have a JUnit test case as: @RunWith(Parameterized.class) public class TestMyClass { @Parameter private int expected; @Parameter private int actual; @Parameters ...
Anmol Gupta's user avatar
  • 2,907
2 votes
2 answers
481 views

How to see the full set of parameters that fail a parameterized test in IntelliJ?

I have a test class that uses org.junit.runners.Parameterized. How can I identify the full set of parameters out of the set of three that fails in a test in IntelliJ 14?
Martin Schröder's user avatar
2 votes
0 answers
180 views

Osherove's naming conventions for parameterized unit tests?

Roy Osherove in his book "The Art of unit testing" indicates a good tone naming test, but it is at odds with parameterized tests about which he mentions only in passing. Parameterized test easier to ...
Semyon.Khmelev's user avatar
8 votes
3 answers
9k views

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 ...
gerg's user avatar
  • 771
0 votes
0 answers
402 views

nunit-console /runlist does not run certain test's in a list containing parameterized test cases

When running from Powershell with the following command & "c:\Program Files (x86)\Nunit 2.6.4\bin\nunit-console.exe" /runlist=C:.....\ReRunTests.txt "C:.....\bin\debug\Web.Test.UI.dll" and ...
Jones The Brewer's user avatar
326 votes
43 answers
419k views

No tests found for given includes Error, when running Parameterized Unit test in Android Studio

I have tried to run Parameterized Unit Tests in Android Studio, as shown below: import android.test.suitebuilder.annotation.SmallTest; import junit.framework.TestCase; import org.junit.Test; ...
Elye's user avatar
  • 57.3k
1 vote
2 answers
238 views

Smart Unit Tests standalone

I've been working with Smart Unit Tests (formerly Pex) for some time now. Pex had the ability to run as a standalone, command-line application which was really useful for several scenarios (e.g. ...
davidhonfi's user avatar
2 votes
1 answer
4k views

GoogleTest Parameterized Test - Possible To Call SetUp And TearDown Between Parameters?

I have a gtest parameterized class that I would like to call some SetUp and TearDown in between each parameter. I know googletest offers SetUp which is before each test case and SetUpTestCase which is ...
cheddarhead52's user avatar
0 votes
2 answers
1k views

JUnit: inject @Parameterized parameters?

What's the easiest way of injecting a set of parameters to a @Parameterized test class? Use case: I have a regular class that looks like this @RunWith(Parameterized.class) class Tests { public ...
Christian Neverdal's user avatar
1 vote
2 answers
10k views

Passing a thread local variable to JUnit test

I have a thread which inits a thread local class variable and starts with running unit tests: public class FooThread extends Thread { TestRunner runner; Foo foo; public void run() { ...
Gobliins's user avatar
  • 3,976
0 votes
1 answer
1k views

Failed TestNG tests with DataProvider in IntelliJ IDEA

i recently started playing around with tdd and ran into a problem where i do not understand why one thing is working and the other one doesnt. the following code works for me: public class Ant { ...
Egon Bert's user avatar
0 votes
1 answer
3k views

JUnit - Looping test cases and comparing the results

I am learning JUnit and I have to test a method multiple times. I have to test the method based on two parameters (Environment and Case#). I am working on two environments where I have to check if ...
dmachop's user avatar
  • 854
1 vote
2 answers
358 views

Use different parameters for particular test

In Junit 4 parameterized testing, if I have 3 tests in test class and I want to use different parameter for particular test, how should I do it? Lets say may 3rd test checks whether a particular ...
Darshana's user avatar
  • 2,502
2 votes
0 answers
176 views

How to know the name of the child class from the parent's static code in Junit framework

I am using Junit framework and writing parameterized testing. I have a base abstract class which is extended by multiple test case classes. Is there a way to find out the test case class name from ...
user3563327's user avatar
6 votes
2 answers
7k views

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....
Juergen's user avatar
  • 3,581
2 votes
2 answers
1k views

why this is not working - Unit testing a synchronous method using parameterized data of Junit?

I am trying to learn the JUnit and wanted to extend it to test in a multi-threaded way. The class I want to test is PrimeNumberValidator. This just tests if a passed in number is prime or not. ...
texpert's user avatar
  • 205
2 votes
3 answers
4k views

deep within JUnit Parameterized test runner: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.util.List

I'm attempting to build my first parameterized test using JUnit's ParameterizedTestRunner. I am getting a weird ClassCastException deep in the bowels of JUnit which I cannot figure out. Here's what'...
Gordon Morehouse's user avatar
15 votes
2 answers
6k views

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 ...
Bryan Mau's user avatar
  • 155
1 vote
0 answers
213 views

Eclipse parameterized test freeze with JUnit 4.11

Configured eclipse indigo SR2 to use junit 4.11 with hamcrest-core-1.3.jar. Whenever test is run in ide with this: @Parameters(name = "{0}") the JUnit console halts at zero. e.g. "0/100". It ...
John Doe's user avatar
  • 1,384