karate

karatelabsMIT活跃维护

用一套简洁的 DSL 同时搞定 API 测试、断言、Mock 服务和性能测试,还能复用为契约测试,省去拼装多套测试框架的麻烦。

Test Automation Made Simple

v2.1.4发布于 2026-10-22 07:56 UTC9,006star2,047fork同步于 2026-11-10 17:31 UTC

怎么上手

README 里没有找到可直接复制的安装命令

README 里没有找到可直接复制的安装命令,请到 README 或官方文档查看安装方式。

硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把 API 测试、Mock、性能测试和 UI 自动化合并到一个统一框架的开源工具

用一套简洁的 DSL 同时搞定 API 测试、断言、Mock 服务和性能测试,还能复用为契约测试,省去拼装多套测试框架的麻烦。

核心能力

  • 用统一框架覆盖 API 测试、Mock、性能测试与 UI 自动化
  • 基于 Maven 中央仓库发布,以 io.karatelabs/karate-core 引入
  • 文档集中在 docs.karatelabs.io 站点
  • v2 版本提供独立模块说明与迁移说明

容易踩的坑

README 主体已迁移到 docs.karatelabs.io,旧版完整说明需查看 v1.5.2.RC2 标签;v2 存在模块与迁移变化,需先读 README_V2.md

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.1.4
  1. v2.1.4最新正式版2026-10-22 · 2026-10-22 07:56 UTC

    ⚠️ Breaking Changes

    These all tighten the mock server's defaults for handling request data and are unlikely to affect most teams. If you don't use Karate mocks, nothing here needs action. If you do, a mock that runs processes, or resolves markers or embedded expressions from files and values built at runtime, opts back in with one configure line, given in each bullet.

    • Mock server: karate.exec() / karate.fork() are off by default in a mock; configure javaBridgeEnabled = true turns them back on #3067
    • Mock server: a match / karate.match() marker that names a variable (#[] schema, ##(schema), #? _ == expected) resolves only when written in the mock feature itself; a marker held in a read() schema or built at runtime fails with a message naming the opt-in, configure requestExpressionsEnabled = true #3067
    • Mock server: an embedded #(...) inside a value built by JS (({ a: '#(' + name + ')' }), a karate.call() result, a file read through an ext provider) is left verbatim unless that exact token is written in the mock feature or a file it read()s; configure requestExpressionsEnabled = true restores evaluation #3067
    • Mock server: a feature called from a mock (call, callonce, karate.call()) runs with the mock's defaults — Java.type(), karate.exec() / karate.fork() are off and request data it receives stays inert; a helper that needs them has the mock opt in with configure javaBridgeEnabled = true / configure requestExpressionsEnabled = true #3067

    Important Fixes

    • Mock server: karate.request is treated as request data, and an XML request body is untrusted like a JSON one #3067
    • Reports mask credential headers (Authorization, Cookie, Set-Cookie, Proxy-Authorization) as *** by default in HTML, JSONL, Cucumber JSON and JUnit XML (console unchanged); configure logging = { mask: false } shows them again
    • Gherkin: a step outside a Background / Scenario / Scenario Outline (e.g. after an Examples table) is a parse error naming its line instead of being silently skipped, as in Cucumber
    • JS engine: a stray token after a complete statement on the same line (var x = 'a' b) is reported as a SyntaxError, with a hint when a doubled or stray quote is the likely cause
    • Mock server: Background functions no longer nest one wrapper per request until StackOverflowError #3081
    • Mock server: an explicit Content-Type is kept when the response body is a string #3074
    • Mock servers started with karate.start() are stopped when the scenario (or Suite) that started them ends, so ports are released #3096
    • driver.quit() in a called feature releases the pooled driver, so later browser starts no longer time out (2.1.3 regression) #3093
    • Appium driver types (android / ios) no longer silently start desktop Chrome; an unsupported driver type fails fast (2.1.3 regression) #3092
    • Gatling: concurrent users are no longer capped at CPU×2 (each feature runs on a virtual thread), and a KO from a failed custom perf event is reported once on the right row #3094
    • A feature-level @ignore no longer skips the feature when a :line filter selects a scenario (v1 → v2 regression) #3083
    • Scenario Outline Examples columns no longer freeze to row 1 after karate.set(callSingle(...)) of a target with a nested call / callonce #3080
    • karate.match() 2-arg form resolves dot-notation variable references inside #(...) / ##(...) / #[] schema markers #3066
    • HTML report pass % reads 100 only when nothing failed (3120 of 3121 is 99%) #3065
    • A Gherkin description line starting with a step keyword (e.g. When paused, ... under Feature:) no longer drops the Background that follows
    • Server mode: the session cookie is Secure only over https, so sessions survive plain http on a LAN IP or container hostname

    New Features & Enhancements

    • configure afterFeature hook; ScenarioRuntime.currentOrNull() is available in Java glue during it #3097
    • Mock variables are readable from t
  2. v2.1.32026-09-27 · 2026-09-27 05:16 UTC
    查看更新说明

    Important Fixes

    • karate.call() with a real HTTP request no longer repeats the first response when called in a loop with updated params (2.1.1 → 2.1.2 regression) #3030
    • karate run with karate-pom.json no longer runs every feature twice (2.1.2 standalone) #3041
    • A feature-level @fail tag is inherited by every scenario in the feature (v1 → v2 regression) #3029
    • karate.read() no longer corrupts .xlsx and other Office / zip-based files #3021
    • read() accepts a dynamic, concatenated path expression #3022
    • Browser file upload restored via inputFile() for both CDP and W3C backends #3015
    • byte[] variables are no longer shared by reference through callonce / callSingle caches, and primitive arrays no longer crash on unchecked casts #3014
    • Error output shows the file name and line number everywhere #3024
    • Cucumber JSON report scenarios carry start_timestamp again #3047
    • optional('#missing').click() does nothing for an absent element instead of throwing #3042
    • driver.script() no longer adds an extra invocation to an arrow IIFE #3046
    • JSON.stringify() keeps the quotes when serializing a scalar string #3043
    • An explicitly constructed java.lang.String keeps hashCode and equalsIgnoreCase #3045
    • The Java String constructor works when its byte-array argument is a method call #3044
    • Mock server: pathParams, requestUrlBase and requestMethod are treated as untrusted request data like the other request variables, and the file session store rejects crafted session ids #3064
    • An Error thrown past a step now fails its scenario instead of reading as passed

    New Features & Enhancements

    • JS engine: class static initialization blocks, structuredClone and performance.now globals, and many spec-conformance fixes
    • Match: match, karate.match and assert fire a MATCH_EXIT run event for listeners
    • HTTP: Http.quiet() for callers that treat a 4xx/5xx as a normal outcome; a mock's response.body can be mutated in place
    • Run events: every scenario execution carries a run-unique executionIndex, and a listener failure no longer keeps an event out of the stream
    • Gatling: the log replay names each scenario and descends into called features
    • Logging: the bundled logback.xml sets only parent loggers, so the default console matches the docs; logging.console precedence is documented #3031
    • Server mode: ka:data, ka:vals, ka:dispatch and the ka: → hx-* helpers escape values that would end the attribute
    • Security docs: SECURITY.md now states the scope for reports — Karate, including the mock server, is test tooling for trusted networks only
    • Dependency bumps: netty 4.2.18.Final, jackson-bom 2.22.3, slf4j 2.0.20, logback 1.6.4

    View the complete list of all issues fixed in this release.

    Full Changelog: https://github.com/karatelabs/karate/compare/v2.1.2...v2.1.3

    Important: refer 2.0.0 release notes for those upgrading from 1.X

    Artifacts

  3. v2.1.22026-08-14 · 2026-08-14 04:26 UTC
    查看更新说明

    Important Fixes

    • ##(schema) optional-marker semantics now apply to schema references — a null value passes #3006
    • The method keyword resolves variables again (v2 regression) #2997
    • karate.sort(list) works with a single argument as documented — the key function is optional #2996
    • get[0] with a JsonPath filter returns [] instead of erroring when the path traverses a null node #2995
    • call / callonce with read() no longer drops a callee-defined key that shares a name with a caller variable #2991
    • NDJSON response bodies are kept as raw text instead of being silently truncated by JSON parsing #2990
    • afterScenario hook scope is no longer frozen to the first scenario when Background uses callonce with HTTP #2988
    • set accepts a multi-line docstring expression #2978
    • text/plain responses are no longer parsed as JSON just because the body starts with a brace #2977
    • #(!^part) schema macro no longer false-passes on a list of objects #2976
    • match contains only deep respects element multiplicity instead of matching differing multisets #2975
    • Numeric match == no longer equates distinct integers above 2^53 #2974
    • karate.callSingle / karate.call arguments are passed consistently to classpath: JS functions across scenarios #2973
    • OOM under parallel execution fixed — embedded-expression processing no longer deep-copies every variable in scope on every step #2972
    • Report keeps per-step / HTTP detail for karate.callSingle() calls made during karate-config.js resolution #2967

    New Features & Enhancements

    • JS engine: async / await / Promise runtime with setTimeout support
    • JS engine: private class fields, methods and accessors; WeakMap / WeakSet; labeled statements with break / continue
    • JS engine: significant performance work — slot-frame resolution for function locals, token caches, static binary operators
    • Image: new pixelmatch comparison engine with cluster verdict and ignoredBoxes #2987
    • HTTP: csv, yaml, toml and markdown are recognized named content-types
    • Mocks: a Karate mock discloses itself on the wire via a Karate-Mock response header
    • Gatling: failure detail aligned across the KO message and log output #2998
    • Memory: a step's captured logs and embeds are released at feature end, and suite-exit no longer re-ships the whole run
    • A dry run no longer prints as a green pass, and its result says so
    • A missing karate-config.js is logged at INFO instead of WARN
    • Dependency bumps: jackson-bom 2.22.1

    View the complete list of all issues fixed in this release.

    Full Changelog: https://github.com/karatelabs/karate/compare/v2.1.1...v2.1.2

    Important: refer 2.0.0 release notes for those upgrading from 1.X

    Artifacts

  4. v2.1.12026-07-15 · 2026-07-15 10:14 UTC
    查看更新说明

    Important Fixes

    • karate.match() inside a closure passed across feature files resolves variables in the calling scope, not the defining scope #2966
    • karate.remove() now removes nested JSON fields #2953
    • get[0] with a JsonPath filter on a missing property degrades to #notpresent instead of erroring #2950
    • call / callonce with read() no longer returns the entire caller scope in the result #2949
    • callonce inside a call read() no longer caches globally across invocations #2941
    • Escaped pipe \| in Examples tables is treated as a literal pipe character #2943
    • param with a null value omits the query parameter instead of failing #2942
    • afterFeature now fires as expected when running with multiple threads #2939
    • karate.set(callSingle()) with call read() in Background no longer freezes Scenario Outline row values #2934
    • karate.set(callSingle()) with the disk cache no longer wipes config-level Java.type() variables #2933
    • Feature calls made from JS helper files show up in the summary report again #2928
    • Gatling: feature errors are logged, ANSI escapes are stripped from log files, and --no-color is accepted #2937
    • --no-color is applied and stripped before subcommand parsing #2936
    • Gatling: a scenario that fails before any HTTP request emits a synthetic KO instead of vanishing from the report
    • Gatling: feature chaining repaired — the mutable __karate map is matched on read
    • A non-SSE GET against HttpServer is rejected with a real status (405/404) rather than hanging
    • DOM nodes render as XML text instead of crashing json-smart
    • Driver: page-load waits are bound to the navigation's loaderId, closing a class of races on redirects and replaced loaders
    • Driver: each pooled slot gets its own browser context, and tab enumeration is scoped to the driver's own context

    New Features & Enhancements

    • The HTML report opens far faster and uses much less memory on large features — syntax highlighting is deferred until a block is viewed #2938
    • Failures pinpoint the feature-file location, with a richer failure console #2952
    • Driver: select() fires the full real-selection event sequence (input, change, blur, focusout)
    • Driver: new CdpDriver.objectId(locator) for locator to CDP-node resolution
    • CDP: named init-script registry, plus DOM.getFrameOwner / describeNode and script/binding injection wrappers
    • WebSocket: subprotocol negotiation support in WsClient
    • HTTP: bind-host support on HttpServer for localhost-only hardening
    • BootLoader.bootOnly, BootBinding.getGlobals() and ConfigLoader.configOnly — evaluate boot and config without running features
    • Report: kind-labelled embed badges, skipped tiles, and Scenario Outline badges
    • Dependency bumps: Selenium, the Scala / Gatling plugins, and central-publishing-maven-plugin

    View the complete list of all issues fixed in this release.

    Full Changelog: https://github.com/karatelabs/karate/compare/v2.1.0...v2.1.1

    Important: refer 2.0.0 release notes for those upgrading from 1.X

    Artifacts

  5. v2.1.02026-06-17 · 2026-06-17 04:48 UTC
    查看更新说明

    ⚠️ Breaking Changes

    • Mock servers no longer evaluate untrusted request data as code by default. Java interop (Java.type) and embedded-expression evaluation of request-derived data (request, requestHeaders, requestParams) are now off by default for mocks, closing a remote-code-execution risk. A mock that uses Java interop or templates off request content must opt in — add configure javaBridgeEnabled = true and/or configure requestExpressionsEnabled = true to the mock Background (or set .javaBridgeEnabled(true) / .requestExpressionsEnabled(true) on MockServer.Builder). #2927

    Important Fixes

    • match through a null/undefined/absent intermediate path degrades to #notpresent and never resolves a same-named variable in scope (e.g. a Scenario-Outline Examples column) #2926 #2906
    • #notpresent works across multiple Examples columns on absent paths #2924
    • Gatling simulations auto-read -Dkarate.env / KARATE_ENV again #2925
    • <column> expansion of an object column in a dynamic Scenario Outline #2921
    • schema cross-references resolve when loaded via call read() #2919
    • configure headers/cookies mutations to the source object are reflected per-request #2918
    • get with a JsonPath filter [?(@.field=='value')] no longer returns null #2916
    • call read('file.js')(args) immediately-invoked JS parses correctly #2915
    • JS-driven feature calls (karate.call) appear in the report and summary #2914
    • #(variable) in an Examples table no longer throws ReferenceError when the called feature uses callSingle #2913
    • @setup scenario can be called by tag / manually #2908
    • HTML report pass% (donut) reconciled with the totals row when scenarios are skipped #2907
    • __arg is defined for called scenarios and top-level runFeature(path, arg) #2905
    • bytes datatype keyword wired up #2904
    • per-Engine isolation of built-in constructors and prototypes #2920
    • browser driver: re-arm OOPIF auto-attach across pooled-driver reuse and CDP session switches #2922
    • afterScenario hook runs before driver/channel teardown #2923

    New Features & Enhancements

    • console logging can be fully silenced — new off / none levels #2917
    • author-set __id for stable scenario identity, plus karate.scenario.slug
    • request.bodyJson convenience accessor
    • HTML report KPI summary-card hook; scenarios show effective (inherited) tags
    • karate.getConfigDir() exposes the resolved karate-config.js directory
    • dry-run reports steps as skipped (not passed)

    View the complete list of all issues fixed in this release.

    Full Changelog: https://github.com/karatelabs/karate/compare/v2.0.10...v2.1.0

    Important: refer 2.0.0 release notes for those upgrading from 1.X

    Artifacts

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Karate

    The open-source tool that combines API testing, mocks, performance testing, and UI automation into a single, unified framework.

    Maven Central Build Status GitHub release Twitter Follow GitHub Stars OpenSSF Scorecard

    The previous README monolith is preserved at:

    github.com/karatelabs/karate/tree/v1.5.2.RC2

    Anchor links (e.g. #syntax-guide, #configuration) can be appended to navigate directly to specific sections.

    See README_V2.md for v2 module descriptions, feature highlights, and migration notes.