I have a problem, I would like to pass the test method to send a request using the GET method and POST. I used parameterization, but I get information java.lang.Exception: Method simpleMessage should have no parameters
@Test
@ParameterizedTest
@ValueSource(strings = {"true", "false"})
public void simpleMessage (boolean isPost) {
verifyIdOdpEqual(isPost,1243, "message");
}
I don't quite understand what you trying to achieve as well but you have few problems with your code:
@ParameterizedTest and @ValueSource I assume you using JUnit 5. At the same time looks like you marked your method with annotation from JUnit 4 (because only in that case you will get an exception with the text you quoted).@Test is redundant when the method is annotated with @ParametrizedTest.You have 2 options how to fix all of the above:
If you want to use junit5 then you need to remove @Test annotation and make sure that your tests are launched by a runner that supports JUnit 5 (more info).
Example:
package test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
public class TestTest {
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void test(boolean data) {
System.out.println(data);
}
}
If you want to use JUnit 4 then you need to remove @ParameterizedTest and @ValueSource annotations and rewrite your test to use parametrized runner (more info).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With