You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
Create a parameter creation method that includes nulls such as:
private Object[] names() {
return $(
$(null),
$(""),
$("Scott"),
$("Shawn"),
$("Steve")
);
}
What is the expected output? What do you see instead?
I'd expect the null string to be passed into the parameter on one of the test
runs, but instead the method blows up when trying to create the Object[]. The
reason for this is "documented" in (hidden) issues reports and/or blog posts
and are completely understandable.
What version of the product are you using? On what operating system?
1.0.0
Please provide any additional information below.
I'd be happy to write the page.
Original issue reported on code.google.com by [email protected] on 13 Sep 2013 at 3:25
The text was updated successfully, but these errors were encountered:
For those finding this page via Google, including objects that can't be parsed
from a CSV string in the arguments passed to a test can be accomplished as
shown in the following snippet:
private static final Object DEFAULT_VALUE = new String("It works!");
private static final Object OTHER_VALUE = new String("It's broken!");
private Object foo(String input) {
Object output = DEFAULT_VALUE;
if(input != null && !"".equals(input.trim())) {
output = OTHER_VALUE;
}
return output;
}
@SuppressWarnings("unused")
private Object[] parameters() {
return $(
new Object[] { null },
new Object[] { "" },
new Object[] { " " }
// ,"Other value"
);
}
@Test
@Parameters(method = "parameters")
public void testing(String input) {
Object obj = foo(input);
assertEquals(obj, DEFAULT_VALUE);
}
This code was posted as an answer to a question on StackOverflow
(http://stackoverflow.com/questions/20389114/junit-same-testcase-with-different-
inputs) and can be used as the basis for the suggested wiki page, since my
experience is that sending null and empty Strings is the most common
problematic case.
Original issue reported on code.google.com by
[email protected]
on 13 Sep 2013 at 3:25The text was updated successfully, but these errors were encountered: