Switch from parameterized test to individual tests
Make the test failure explicit and visible in the build log
@@ -9,39 +9,30 @@ import com.gargoylesoftware.htmlunit.AlertHandler;
import com.gargoylesoftware.htmlunit.ScriptResult;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.model.UnprotectedRootAction;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestExtension;
-@RunWith(Parameterized.class)
public class Security2779Test {
public static final String URL_NAME = "security2779";
- private final String selector;
+
@Rule
public JenkinsRule j = new JenkinsRule();
- // Dynamic tests are not fully supported by the maven surefire plugin
- // Failures of one parameter are treated as "flakes" of the named test
- // instead of being treated as failures.
- // Test output includes the test number and argument to make it a little easier to diagnose
- @Parameterized.Parameters(name = "test:{index} arg:\"{0}\"")
- public static Collection<String> getSelectors() {
- return Arrays.asList("#link-panel a", "#icon-panel svg");
+ @Test
+ public void noXssInHelpLinkPanel() throws Exception {
+ noCrossSiteScriptingInHelp("#link-panel a");
}
- public Security2779Test(String selector) {
- this.selector = selector;
+ @Test
+ public void noXssInHelpIconPanel() throws Exception {
+ noCrossSiteScriptingInHelp("#icon-panel svg");
}
- @Test
- public void noXssInHelp() throws Exception {
+ private void noCrossSiteScriptingInHelp(String selector) throws Exception {
final AtomicInteger alerts = new AtomicInteger();
final JenkinsRule.WebClient webClient = j.createWebClient();
webClient.setAlertHandler((AlertHandler) (p, s) -> alerts.addAndGet(1));
