当前位置: 首页 > 知识库问答 >
问题:

在Jenkins的作业中,行为测试在任何失败后都会停止

易扬
2023-03-14
    cd ~/FEXT_BETA_BDD
    rm -rf allure_reports  allure-reports  allure-results 
    pip install behave
    pip install selenium
    pip install -r features/requirements.txt

    # execute features in plan section
    behave -f allure_behave.formatter:AllureFormatter -f pretty -o ./allure-reports 
        ./features/plan/*.feature

    # execute features in blueprint section
    behave -f allure_behave.formatter:AllureFormatter -f pretty -o ./allure-reports 
        ./features/blueprint/*.feature
"
    ...
    0 features passed, 1 failed, 0 skipped
    0 scenarios passed, 1 failed, 0 skipped
    3 steps passed, 1 failed, 1 skipped, 0 undefined
    Took 2m48.770s
    Build step 'Execute shell' marked build as failure
    "

谢谢,

千斤顶

共有1个答案

陆翔飞
2023-03-14

您可以尝试以下语法:

set +e

# execute features in plan section
behave -f allure_behave.formatter:AllureFormatter -f pretty -o ./allure-reports 
        ./features/plan/*.feature || echo 'ALERT: Build failed while running the plan section'

# execute features in blueprint section
behave -f allure_behave.formatter:AllureFormatter -f pretty -o ./allure-reports 
        ./features/blueprint/*.feature || echo 'ALERT: Build failed while running the blueprint section'

# Restoring original configuration
set -e

注:

  • SET-E的目标是使shell在发生错误时中止。如果您将看到日志输出,您将在执行开始时注意到sh-xe,这确认了Jenkins中的execute shell使用了-e选项。因此,要禁用它,可以改用+e。但是,在您的目的实现后,最好将其还原,以便后续命令产生预期结果。
 类似资料:
  • 问题内容: 我有一个Jenkins作业,它通过Nightwatch.js框架在Browserstack上运行Selenium测试。我们有一套完整的测试程序,可以让守夜人在不同的进程中运行,并且我们需要一种在所有测试运行后将通过/失败值返回给Jenkins的方法。 我一直在尝试使用Nightwatch挂钩在每个模块的末尾运行一段代码,但是我无法弄清楚需要采取什么措施才能使Jenkins作业可以访问该

  • 我试图用jenkins execution命令测试我的java项目,但是我得到了以下错误消息: 有关单个测试结果,请参阅/var/jenkins_home/workspace/test1/target/surefire-reports。请参阅转储文件(如果存在)[date].dump,[date]-jvmrun[N].dump和[date].dumpstream。分叉的VM在没有正确地说再见的情况

  • 我按照cypress在他们的文档中推荐的方式编写测试,即每个测试有多个断言,但是用这种方式编写测试时会出现一个问题,那就是如果断言失败,测试执行就会停止。 我希望每个测试有多个断言,如果其中一个失败,测试将失败,但将继续测试执行,所以在最后,我将能够看到测试中失败的所有断言,而不仅仅是第一个失败的断言。 提前感谢!

  • 我已经在Netbeans上通过JS测试驱动程序设置了JavaScript单元测试。然而,与该教程中的结果不同,断言失败后不会执行更多测试。我怎样才能改变这种行为? 例如,给定此测试文件: 文件: 进度条显示50%,(2次测试),应该是33%。 文件: 我可以通过命令行运行所有测试。(在Windows PowerShell上)。按如下方式运行,失败后测试不会停止运行: java-jar$env: J

  • 我在本地安装了两个Docker容器,其中包括Jenkins和Selenium。我有一个用Java编写的Maven项目,其中我创建了一套使用Selenium实现的E2E(端到端)测试。从IntelliJ的终端,使用“mvn测试”(或mvn清洁测试或其他组合)命令,测试正在运行,即使我对Chrome驱动程序使用headless或not。另外,这是用POM编写的插件之一: XML套件文件包含每个自动测试

  • 如果Jenkins下游作业的任何上游作业失败或不稳定,那么阻止或失败的最佳方法是什么? 目前,我已经勾选了“当上游项目正在构建时阻止构建”选项,并且运行良好,因为我的下游作业正在等待所有上游作业完成构建。但是,如果任何上游失败或不稳定,我不想构建作业。 谢啦