-
| I'd like to use Named arguments ( #2521 ). But I couldn't understand how to use it with variable length Objects like this test case. I tried this code @DisplayName("A parameterized test with named arguments")
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("namedArguments")
void testWithNamedArguments(File file, String str) {
}
static Stream<Arguments> namedArguments() {
return Stream.of(arguments(Named.of("An important file", new Object[] {new File("path1"), "foo"})),
	arguments(Named.of("Another file", new Object[]{new File("path2"), "bar"})));
}and got . I'd be thankful for any hint. | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            sbrannen
          
      
      
        Oct 6, 2021 
      
    
    Replies: 1 comment 3 replies
-
| Only the file is a "named" argument. Use the following to achieve your goal. 	static Stream<Arguments> namedArguments() {
		return Stream.of(
			arguments(named("An important file", new File("path1")), "foo"),
			arguments(named("Another file", new File("path2")), "bar")
		);
	} | 
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
      Answer selected by
        ktrueda
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Only the file is a "named" argument.
Use the following to achieve your goal.