Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to rewrite data-driven test suites of JUnit 3 in Junit 4?
    primarykey
    data
    text
    <p>I am using data-driven test suites running JUnit 3 based on <a href="http://rads.stackoverflow.com/amzn/click/1932394230" rel="nofollow noreferrer">Rainsberger's JUnit Recipes</a>. The purpose of these tests is to check whether a certain function is properly implemented related to a set of input-output pairs.</p> <p>Here is the definition of the test suite:</p> <pre><code>public static Test suite() throws Exception { TestSuite suite = new TestSuite(); Calendar calendar = GregorianCalendar.getInstance(); calendar.set(2009, 8, 05, 13, 23); // 2009. 09. 05. 13:23 java.sql.Date date = new java.sql.Date(calendar.getTime().getTime()); suite.addTest(new DateFormatTestToString(date, JtDateFormat.FormatType.YYYY_MON_DD, "2009-SEP-05")); suite.addTest(new DateFormatTestToString(date, JtDateFormat.FormatType.DD_MON_YYYY, "05/SEP/2009")); return suite; } </code></pre> <p>and the definition of the testing class:</p> <pre><code>public class DateFormatTestToString extends TestCase { private java.sql.Date date; private JtDateFormat.FormatType dateFormat; private String expectedStringFormat; public DateFormatTestToString(java.sql.Date date, JtDateFormat.FormatType dateFormat, String expectedStringFormat) { super("testGetString"); this.date = date; this.dateFormat = dateFormat; this.expectedStringFormat = expectedStringFormat; } public void testGetString() { String result = JtDateFormat.getString(date, dateFormat); assertTrue( expectedStringFormat.equalsIgnoreCase(result)); } } </code></pre> <p>How is it possible to test several input-output parameters of a method using JUnit 4?</p> <p><a href="https://stackoverflow.com/questions/2635839/junit-confusion-use-extend-testcase-or-test">This question</a> and the answers explained to me the distinction between JUnit 3 and 4 in this regard. <a href="https://stackoverflow.com/questions/457276/junit4-test-suites">This question</a> and the answers describe the way to create test suite for a set of class but not for a method with a set of different parameters.</p> <p><strong>Solution</strong>:</p> <p>Based on drscroogemcduck's answer this is <a href="http://isagoksu.com/2009/development/agile-development/test-driven-development/using-junit-parameterized-annotation/" rel="nofollow noreferrer">the exact page</a> what helped.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload