テストをパラメータ化するために JunitParams を使用しようとしています。しかし、私の主な問題は、パラメーターが特殊文字、チルダ、またはパイプを含む文字列であることです。
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
@RunWith(JUnitParamsRunner.class)
public class TheClassTest {
@Rule
public ExpectedException exception = ExpectedException.none();
@Test
@Parameters({"AA~BBB"})
public void shouldTestThemethod(String value) throws Exception {
exception.expect(TheException.class);
TheClass.theMethod(value);
// Throw an exception if value like "A|B" or "A~B",
// ie if value contain a ~ or a |
}
}
チルダで、私は問題ありません。ただし、パイプには例外があります。
java.lang.IllegalArgumentException: wrong number of arguments
パイプはコンマとして、パラメーターの区切りとして使用されます。
別のセパレータを設定する方法はありますか? それとも、これは JunitParams の制限ですか?