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
2
votes
3 answers

Testing for optional exception in parameterized JUnit 4+ test

I am trying to write a unit test for a method which takes a string as a para- meter and throws an exception if it is malformed (AND NONE if it is okay). I want to write a parameterized test which feeds in several strings and the expected exception…
2
votes
2 answers

Kotlin Junit5 ValueSource as an array variable

I have a map of key and values and I want to add the keys as array to ValueSource but I've got error.Where am I wrong? Here's my code private val id = mapOf("abc" to 10001,"def" to 955,"ghi" to 804,"jkl" to 805) private val ids:Array
24t7it3
  • 23
  • 4
2
votes
2 answers

Customizing pytest parameterized test name

I've the following tests: @pytest.mark.parametrize( "nums", [[3, 1, 5, 4, 2], [2, 6, 4, 3, 1, 5], [1, 5, 6, 4, 3, 2]] ) def test_cyclic_sort(nums): pass @pytest.mark.parametrize( "nums, missing", [([4, 0, 3, 1], 2)] ) def…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
2
votes
1 answer

When using JUnit's @Parameterized, can I skip few test data due to bug?

@RunWith(value = Parameterized::class) class A(private val a: aa, private val b: bb, private val c: cc, private val d: dd ) : UIAutomatorTestCase() { @Test fun testMethodA() { } companion object { …
Shah
  • 553
  • 5
  • 12
2
votes
0 answers

Jest test.each with object property in name

I have a parameterized test: test.each([myObjWithMyPropertyTrue, myObjWithMyPropertyFalse]) ('should do something when %o', (myObj) => { but instead of printing the entire object with %o, I want to print the value of property…
eriksmith200
  • 2,159
  • 5
  • 22
  • 33
2
votes
1 answer

SWI-Prolog - Unit testing library plunit - How is forall option used?

For my lexer (tokenizer) all of the ASCII 7-bit characters (0x00 to 0x7F) have a specific token. As SWI-Prolog supports Unicode, the character codes go from 0x0000 to 0xFFFF. In my lexer, since there are many characters that will not map to a…
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
2
votes
1 answer

Parameterized tests that use a custom test runner

We are using our custom test runner, that extend ParentRunner: public class OurTestRunner extends ParentRunner {...} class TestRunnerForOneConfigCase extends BlockJUnit4ClassRunner {...} Inspired by how to combine…
Grzenio
  • 35,875
  • 47
  • 158
  • 240
2
votes
2 answers

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 result obtained in A. In other words, I would…
Nana89
  • 432
  • 4
  • 21
2
votes
2 answers

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(unittest.TestCase): def setUp(self): …
2
votes
2 answers

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
  • 4,176
  • 7
  • 47
  • 81
2
votes
0 answers

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 write, in some aspects, and read. But there are…
2
votes
1 answer

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 before ALL test cases. I have something like…
2
votes
0 answers

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 the static code of the base abstract class. Any…
2
votes
2 answers

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. package com; public class PrimeNumberValidator { …
2
votes
3 answers

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's weird about this: the traceback in Intellij…