我有一个maven项目,它通过JMeter运行一些回归测试用例(非负载测试)。
这里我设置了这个项目在Jenkins中执行。
的Maven。 我正在使用jmeter-maven-plugin(v2.0.3)来执行Jmeter测试。
的JMeter Jmeter 3.0(ApacheJMeter-3.0.jar虽然jmeter-maven-plugin) 该项目的设置遵循this page中所述的相同方法。
詹金斯。 该项目在Jenkins(v1.618)上配置为自由风格项目。
当我执行项目时,执行测试手势并生成仪表板。构建以[INFO] BUILD SUCCESS完成。
由于Maven Build成功,Jenkins总是将构建显示为成功构建。即使JMtere测试失败,Jenkis也会将构建标记为成功。
如何将JMtere回归测试失败传播给Jenkins?
我不需要使用和加载测试报告插件,因为这些并不是负载测试和回归测试。
我的构建日志的相关部分如下所示。
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TestProj Regression Test Suite 0.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ TestProj-regression ---
[INFO] Deleting C:\Users\Testuser\Documents\TestProj\TestProj_Regression\target (includes = [**/*.csv, **/*], excludes = [])
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (Deleting all files under target, but not target itself) @ TestProj-regression ---
[INFO] Deleting C:\Users\Testuser\Documents\TestProj\TestProj_Regression\target (includes = [**/*.csv, **/*], excludes = [])
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:copy-resources (copy-resources) @ TestProj-regression ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 11 resources
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ TestProj-regression ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\Testuser\Documents\TestProj\TestProj_Regression\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ TestProj-regression ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ TestProj-regression ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 697 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ TestProj-regression ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ TestProj-regression ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ TestProj-regression ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\Users\Testuser\Documents\TestProj\TestProj_Regression\target\TestProj-regression-0.1.0-SNAPSHOT.jar
[INFO]
[INFO] >>> jmeter-maven-plugin:2.0.3:jmeter (execute-jmeter-tests) > :configure @ TestProj-regression >>>
[INFO]
[INFO] --- jmeter-maven-plugin:2.0.3:configure (configure) @ TestProj-regression ---
[INFO] -------------------------------------------------------
[INFO] Configuring JMeter...
[INFO] -------------------------------------------------------
[INFO]
[INFO] <<< jmeter-maven-plugin:2.0.3:jmeter (execute-jmeter-tests) < :configure @ TestProj-regression <<<
[INFO]
[INFO] --- jmeter-maven-plugin:2.0.3:jmeter (execute-jmeter-tests) @ TestProj-regression ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] P E R F O R M A N C E T E S T S
[INFO] -------------------------------------------------------
[INFO] Invalid value detected for <postTestPauseInSeconds>. Setting pause to 0...
[INFO]
[INFO]
[INFO] Executing test: TestProj_Regression.jmx
[INFO] Writing log file to: C:\Users\Testuser\Documents\TestProj\TestProj_Regression\target\jmeter\logs\TestProj_Regression.jmx.log
[INFO] Creating summariser <summary>
[INFO] Created the tree successfully using C:\Users\Testuser\Documents\TestProj\TestProj_Regression\target\jmeter\testFiles\TestProj_Regression.jmx
[INFO] Starting the test @ Tue Dec 13 17:03:33 AEDT 2016 (1481609013485)
[INFO] Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
[INFO] Base Dir root [C:/Users/Testuser/Documents/TestProj/TestProj_Regression/target/jmeter]
[INFO] DEbug line 3
[INFO] envFlag: [TestEnv1]
[INFO] baseDir: [C:/Users/Testuser/Documents/TestProj/TestProj_Regression/target/jmeter]
[INFO] dataFilesPath: [C:/Users/Testuser/Documents/TestProj/TestProj_Regression/target/jmeter/TestProjRegression/DataFiles/TestEnv1]
[INFO] runConfigFilesPath:[C:/Users/Testuser/Documents/TestProj/TestProj_Regression/target/jmeter/TestProjRegression/RunConfig]
[INFO] outputFilesPath: [C:/Users/Testuser/Documents/TestProj/TestProj_Regression/target/jmeter/TestProjRegression/OutputFiles/TestEnv1]
[INFO] resultsPath: [C:/Users/Testuser/Documents/TestProj/TestProj_Regression/target/jmeter/TestProjRegression/Results/TestEnv1]
[INFO] Config File [C:/Users/Testuser/Documents/TestProj/TestProj_Regression/target/jmeter/TestProjRegression/RunConfig/RunConfig_TestEnv1.csv]
[INFO].
[INFO].
[INFO].
[INFO].
[INFO].
[INFO] summary + 1 in 00:00:00 = 4.2/s Avg: 149 Min: 149 Max: 149 Err: 0 (0.00%) Active: 1 Started: 1 Finished: 0
[INFO].
[INFO].
[INFO].
[INFO].
[INFO] summary + 1 in 00:00:18 = 0.1/s Avg: 7496 Min: 7496 Max: 7496 Err: 1 (100.00%) Active: 0 Started: 1 Finished: 1
[INFO] summary = 2 in 00:00:18 = 0.1/s Avg: 3822 Min: 149 Max: 7496 Err: 1 (50.00%)
[INFO] Tidying up ... @ Tue Dec 13 17:03:52 AEDT 2016 (1481609032067)
[INFO] ... end of run
[INFO] Completed Test: TestProj_Regression.jmx
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (default) @ TestProj-regression ---
[INFO] Executing tasks
[mkdir] Created dir: C:\Users\Testuser\Documents\TestProj\TestProj_Regression\target\jmeter\results\dashboard
[copy] Copying 1 file to C:\Users\Testuser\Documents\TestProj\TestProj_Regression\target\jmeter\bin
[copy] Copying 696 files to C:\Users\Testuser\Documents\TestProj\TestProj_Regression\target\jmeter\bin\report-template
[java] Writing log file to: C:\Users\Testuser\Documents\TestProj\TestProj_Regression\jmeter.log
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:57 min
[INFO] Finished at: 2016-12-13T17:04:13+11:00
[INFO] Final Memory: 18M/185M
[INFO] ------------------------------------------------------------------------
[INFO] Shutdown detected, destroying JMeter process...
答案 0 :(得分:1)
最快,最简单的方法是使用Performance Plugin,它具有在单个构建或历史结果上定义错误阈值的功能
此外,您将拥有&#34;表现趋势&#34;您的构建仪表板上的图表,以便您能够跟踪(希望)您的应用程序性能的积极动态。
替代方法是使用Taurus工具作为JMeter测试的包装而不是Maven,它提供了强大而灵活的Pass/Fail Criteria子系统,您可以在其中指定失败条件。如果超过指定的阈值 - Taurus将只返回非零退出代码,而Jenkins足够智能将其视为步骤失败。