From fe8319f971b9af365e44b7e14dcbb85ba30a3134 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 9 Dec 2012 05:48:31 -0800 Subject: [PATCH] alert should be considered a test failure unless overridden by the test case --- .../main/java/org/jvnet/hudson/test/HudsonTestCase.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 63dc15e7c5..312435b23b 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -24,6 +24,7 @@ */ package org.jvnet.hudson.test; +import com.gargoylesoftware.htmlunit.AlertHandler; import com.gargoylesoftware.htmlunit.html.HtmlImage; import com.google.inject.Injector; import hudson.ClassicPluginStrategy; @@ -1659,6 +1660,12 @@ public abstract class HudsonTestCase extends TestCase implements RootAction { } }); + setAlertHandler(new AlertHandler() { + public void handleAlert(Page page, String message) { + throw new AssertionError("Alert dialog poped up: "+message); + } + }); + // avoid a hang by setting a time out. It should be long enough to prevent // false-positive timeout on slow systems setTimeout(60*1000);