开发者

send email from hudson when unittest fails

开发者 https://www.devze.com 2023-04-11 05:07 出处:网络
I am running Selenium unittests after my hudson build. And want to use it for monitoring my websites functionality.

I am running Selenium unittests after my hudson build. And want to use it for monitoring my websites functionality.

When the build succeeds (which should be always, since it only contains the unittests), hudson will not send email开发者_运维百科s, even when some tests fail.

With email-ext, I could send emails when it becomes unstable, but since browser unittests are somewhat flaky, I do not want them at the first failure, more something like 3 in a row or 80% of the last x-Minutes/runs

Best would be a configuration based on a ruleset based on the testname or something defined in the test which marks it as relevant..


What about using a script for setting the mail content in case of unstable/still-unstable builds alone?

Here, you can add some if conditions for testing the age for the required test cases alone.

<%  if(build.testResultAction) {
    def rootUrl = hudson.model.Hudson.instance.rootUrl
    def jobName = build.parent.name

    def previousFailedTestCases = new HashSet()
    def currentFailedTestCase = new HashSet()

    if(build.previousBuild?.testResultAction){
        build.previousBuild.testResultAction.failedTests.each {
            previousFailedTestCases << it.simpleName +"." + it.safeName
        }
    }

    testResult.failedTests.each{tr ->
          def packageName = tr.packageName
          def className = tr.simpleName
          def testName = tr.safeName
          def displayName = className+"."+testName

          currentFailedTestCase << displayName
          def url = "$HUDSON_URL/job/$PROJECT_NAME/$BUILD_NUMBER/testReport/$packageName/$className/$testName"
          if(tr.age == 1){
            startedFailing << [displayName:displayName,url:url,age:1]
          } else{
            failing << [displayName:displayName,url:url,age:tr.age]
          }
    }

    startedPassing = previousFailedTestCases - currentFailedTestCase

    startedFailing = startedFailing.sort {it.displayName}
    failing = failing.sort {it.displayName}
    startedPassing = startedPassing.sort()
    } %>

Source link : http://techkriti.wordpress.com/2008/08/30/using-groovy-with-hudson-to-send-rich-text-email/


When the build succeeds (which should be always, since it only contains the unittests), hudson will not send emails, even when some tests fail.

I don't know if this is something you want to fix, but if you use the argument

-Dmaven.test.failure.ignore=false

Then Hudson will fail your build if a test fails.

With email-ext, I could send emails when it becomes unstable, but since browser unittests are somewhat flaky, I do not want them at the first failure, more something like 3 in a row or 80% of the last x-Minutes/runs

Your unit tests are minutes/runs? Is this more a performance test than a Unit Test? If it's less a Unit Test and more a Performance / Load Test, we've used JMeter (Hudson has a plugin, as does Maven) with great effect, which allows us to set % when to set the build as unstable or failed.


It sounds like you need two jobs in hudson. One for unittests and one for selenium.

You want the first job to build and run the unittests and have hudson report on the unittests.

In the configuration under "post build actions" you can add a "project to build" and specify your job that builds and runs selenium and reports on those results.

This way you can tweak the thresholds for emails for unit tests to be far more strict than your selenium results.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号