{"id":11283,"date":"2025-02-13T21:20:19","date_gmt":"2025-02-14T02:20:19","guid":{"rendered":"https:\/\/www.redline13.com\/blog\/?p=11283"},"modified":"2025-02-13T21:20:20","modified_gmt":"2025-02-14T02:20:20","slug":"using-test-fragments-in-jmeter","status":"publish","type":"post","link":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/","title":{"rendered":"Using Test Fragments in JMeter Tests"},"content":{"rendered":"<p><a id=\"post-11283-_5a9sb4kng7h0\"><\/a> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-11284\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-1.png\" alt=\"Using Test Fragments in JMeter Tests\" width=\"400\" height=\"300\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-1.png 400w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-1-300x225.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>Test plan design, while not always application programming <em>per se<\/em>, definitely shares some concepts of the latter. A common principle of software development is to minimize repeating code. In this article we will show you how <a href=\"https:\/\/jmeter.apache.org\/usermanual\/component_reference.html#Test_Fragment\" target=\"_blank\" rel=\"noopener\"><em>Test Plan Fragments<\/em><\/a> can be leveraged in <a href=\"https:\/\/jmeter.apache.org\/usermanual\/index.html\" target=\"_blank\" rel=\"noopener\">JMeter<\/a> test plans to reduce repeated elements.<\/p>\n<h3><a id=\"post-11283-_imdjfjvpbldv\"><\/a>Basics of Test Plan Fragments<\/h3>\n<p>In essence, <em>Test Plan Fragments<\/em> are groups of test logic which can be referenced by various JMeter controllers, that do not otherwise execute on their own. They can contain <a href=\"https:\/\/jmeter.apache.org\/usermanual\/component_reference.html#HTTP_Request\" target=\"_blank\" rel=\"noopener\"><em>HTTP Request Samplers<\/em><\/a> and other test plan elements, similar to how <a href=\"https:\/\/jmeter.apache.org\/usermanual\/test_plan.html#thread_group\" target=\"_blank\" rel=\"noopener\"><em>Thread Groups<\/em><\/a> act as containers to group related actions.<\/p>\n<figure id=\"attachment_11285\" class=\"wp-caption aligncenter\" style=\"max-width: 184px\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-11285\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-2.png\" alt=\"An example of a test plan fragment that combines related tasks\" width=\"184\" height=\"55\" \/><figcaption class=\"wp-caption-text\">An example of a test plan fragment that combines related tasks.<\/figcaption><\/figure>\n<p>The usefulness of <em>Test Plan Fragments<\/em> becomes evident when we have a need to repeatedly call a group of related tasks but also need intervening processes to run in between. This can be even more important when test plan flow has variability or branching logic.<\/p>\n<h3><a id=\"post-11283-_mhc8shp22gxp\"><\/a>Example Usage of Test Plan Fragments<\/h3>\n<p>We can illustrate an example use case for Test Plan Fragments by imagining the following requirements. For a retail ordering system, we need to place a set number of orders, then perform a change of the shipping address, and then place additional orders. This also requires that we log into the target test application with user credentials. If we abstract these steps into fragments, we end up with a test plan which looks as follows:<\/p>\n<figure id=\"attachment_11286\" class=\"wp-caption aligncenter\" style=\"max-width: 400px\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-11286\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-3.png\" alt=\"An example of a JMeter test using Test Plan Fragments and Module Controllers to reuse test logic\" width=\"400\" height=\"290\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-3.png 400w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-3-300x218.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><figcaption class=\"wp-caption-text\">An example of a JMeter test using Test Plan Fragments and Module Controllers to reuse test logic.<\/figcaption><\/figure>\n<p>Here, \u201c<em>Retail Workflow<\/em>\u201d is an ordinary <em>Thread Group<\/em>, which contains <em>Module Controllers<\/em> that reference the <em>Test Plan Fragments<\/em> as indicated. The \u201c<em>Place 3 Orders<\/em>\u201d element is a Loop Controller, which as it suggests executes the contained <em>Module Controller<\/em> three times. \u201c<em>Place 2 Orders<\/em>\u201d references the same module controller but executes it only twice.<\/p>\n<p>We can add a <a href=\"https:\/\/jmeter.apache.org\/usermanual\/component_reference.html#View_Results_Tree\" target=\"_blank\" rel=\"noopener\"><em>View Results Tree<\/em><\/a> listener and run this test plan, which produces the following output:<\/p>\n<figure id=\"attachment_11287\" class=\"wp-caption aligncenter\" style=\"max-width: 730px\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-11287\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-4.png\" alt=\"View Results Tree output showing execution of a JMeter test with reusable Test Plan Fragments\" width=\"730\" height=\"351\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-4.png 1136w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-4-300x144.png 300w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-4-1024x493.png 1024w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-4-768x370.png 768w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-4-425x205.png 425w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><figcaption class=\"wp-caption-text\">View Results Tree output showing execution of a JMeter test with reusable Test Plan Fragments.<\/figcaption><\/figure>\n<p>Though this is an illustration of a basic use case, you can achieve much more complicated workflows with drastically reduced repetition of test logic by leveraging reusable <em>Test Plan Fragments<\/em>.<\/p>\n<hr \/>\n<p>Did you know that RedLine13 offers a full-featured, time-limited free trial? \u00a0<a href=\"https:\/\/www.redline13.com\/Service\" target=\"_blank\" rel=\"noopener\">Sign up now<\/a>, and start testing today!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Test plan design, while not always application programming per se, definitely shares some concepts of the latter. A common principle of software development is to minimize repeating code. In this article we will show you how Test Plan Fragments can be leveraged in JMeter test plans to reduce repeated elements. Basics of Test Plan Fragments In essence, Test Plan Fragments are groups of test logic which can be referenced by various JMeter controllers, that do not<a class=\"more-link\" href=\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/\">Read More &rarr;<\/a><\/p>\n","protected":false},"author":11,"featured_media":11284,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1],"tags":[128,283,299,318,424,426],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-dkoziel","4":"post-11283","6":"format-standard","7":"has-post-thumbnail","8":"category-blog","9":"category-uncategorized","10":"post_tag-cloud-load-testing","11":"post_tag-jmeter","12":"post_tag-jmeter-plugins","13":"post_tag-load-testing","14":"post_tag-redline13","15":"post_tag-redline13-customer"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Test Fragments in JMeter Tests - RedLine13<\/title>\n<meta name=\"description\" content=\"In this article we will show you how Test Plan Fragments can be leveraged in JMeter test plans to reduce repeated elements.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Test Fragments in JMeter Tests - RedLine13\" \/>\n<meta property=\"og:description\" content=\"In this article we will show you how Test Plan Fragments can be leveraged in JMeter test plans to reduce repeated elements.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/\" \/>\n<meta property=\"og:site_name\" content=\"RedLine13\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-14T02:20:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-14T02:20:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"David Koziel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"David Koziel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/\"},\"author\":{\"name\":\"David Koziel\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20\"},\"headline\":\"Using Test Fragments in JMeter Tests\",\"datePublished\":\"2025-02-14T02:20:19+00:00\",\"dateModified\":\"2025-02-14T02:20:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/\"},\"wordCount\":417,\"publisher\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\"},\"keywords\":[\"Cloud Load Testing\",\"JMeter\",\"jmeter-plugins\",\"Load Testing\",\"RedLine13\",\"redline13 customer\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/\",\"name\":\"Using Test Fragments in JMeter Tests - RedLine13\",\"isPartOf\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\"},\"datePublished\":\"2025-02-14T02:20:19+00:00\",\"dateModified\":\"2025-02-14T02:20:20+00:00\",\"description\":\"In this article we will show you how Test Plan Fragments can be leveraged in JMeter test plans to reduce repeated elements.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.redline13.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Test Fragments in JMeter Tests\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"name\":\"RedLine13\",\"description\":\"(Almost) Free Load Testing in the Cloud\",\"publisher\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.redline13.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\",\"name\":\"RedLine13\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"contentUrl\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"width\":300,\"height\":68,\"caption\":\"RedLine13\"},\"image\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20\",\"name\":\"David Koziel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g\",\"caption\":\"David Koziel\"},\"url\":\"https:\/\/www.redline13.com\/blog\/author\/dkoziel\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Test Fragments in JMeter Tests - RedLine13","description":"In this article we will show you how Test Plan Fragments can be leveraged in JMeter test plans to reduce repeated elements.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/","og_locale":"en_US","og_type":"article","og_title":"Using Test Fragments in JMeter Tests - RedLine13","og_description":"In this article we will show you how Test Plan Fragments can be leveraged in JMeter test plans to reduce repeated elements.","og_url":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/","og_site_name":"RedLine13","article_published_time":"2025-02-14T02:20:19+00:00","article_modified_time":"2025-02-14T02:20:20+00:00","og_image":[{"width":400,"height":300,"url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2025\/02\/word-image-11283-1.png","type":"image\/png"}],"author":"David Koziel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"David Koziel","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/#article","isPartOf":{"@id":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/"},"author":{"name":"David Koziel","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20"},"headline":"Using Test Fragments in JMeter Tests","datePublished":"2025-02-14T02:20:19+00:00","dateModified":"2025-02-14T02:20:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/"},"wordCount":417,"publisher":{"@id":"https:\/\/www.redline13.com\/blog\/#organization"},"keywords":["Cloud Load Testing","JMeter","jmeter-plugins","Load Testing","RedLine13","redline13 customer"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/","url":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/","name":"Using Test Fragments in JMeter Tests - RedLine13","isPartOf":{"@id":"https:\/\/www.redline13.com\/blog\/#website"},"datePublished":"2025-02-14T02:20:19+00:00","dateModified":"2025-02-14T02:20:20+00:00","description":"In this article we will show you how Test Plan Fragments can be leveraged in JMeter test plans to reduce repeated elements.","breadcrumb":{"@id":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.redline13.com\/blog\/2025\/02\/using-test-fragments-in-jmeter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.redline13.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Using Test Fragments in JMeter Tests"}]},{"@type":"WebSite","@id":"https:\/\/www.redline13.com\/blog\/#website","url":"https:\/\/www.redline13.com\/blog\/","name":"RedLine13","description":"(Almost) Free Load Testing in the Cloud","publisher":{"@id":"https:\/\/www.redline13.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.redline13.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.redline13.com\/blog\/#organization","name":"RedLine13","url":"https:\/\/www.redline13.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","contentUrl":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","width":300,"height":68,"caption":"RedLine13"},"image":{"@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20","name":"David Koziel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g","caption":"David Koziel"},"url":"https:\/\/www.redline13.com\/blog\/author\/dkoziel\/"}]}},"_links":{"self":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/11283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/comments?post=11283"}],"version-history":[{"count":1,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/11283\/revisions"}],"predecessor-version":[{"id":11288,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/11283\/revisions\/11288"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/media\/11284"}],"wp:attachment":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/media?parent=11283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/categories?post=11283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/tags?post=11283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}