def test_condition(self): controller = "TEST_PLAN/TEST_FRAGMENT/CONTROLLER" element = ModuleController(node_path=controller) rendered_doc = element.to_xml() parsed_doc = xmltodict.parse(tag_wrapper(rendered_doc, 'test_results')) assert parsed_doc['test_results']['ModuleController'][ 'collectionProp']['stringProp'][1]['#text'] == "TEST_PLAN"
def test_check(self): with pytest.raises(TypeError): ModuleController(node_path=123)
def test_positive(self): ModuleController(node_path="TEST_PLAN/TEST_FRAGMENT/CONTROLLER")
def test_check2(self): with pytest.raises(ValueError): ModuleController(node_path="CONTROLLER")
def test_check(self): with pytest.raises(RuntimeError): c = "TEST_PLAN/TEST_FRAGMENT/CONTROLLER" ModuleController(node_path=c).append( ModuleController(node_path=c))
from jmeter_api.thread_groups.common_thread_group.elements import CommonThreadGroup if __name__ == "__main__": test_plan = TestPlan(name='NewTestPlan') test_plan.append(HTTPCacheManager(clear_each_iteration=True)) test_plan.append(CommonThreadGroup(continue_forever=True, name='FirstThreadGroup') .append(HttpRequest(host='www.google.com')) .append(HttpRequest(host='www.google.com')) .append(ConstantTimer(delay=1000)) ) second_thread_group = CommonThreadGroup( continue_forever=True, name='SecondThreadGroup') for x in range(20): second_thread_group.append(HttpRequest( host='www.google.com', path=f'/new-{x}', name=f'NewSampler{x}')) second_thread_group.append(ConstantThroughputTimer(targ_throughput=10)) test_plan.append(second_thread_group) test_fragment = TestFragment() lc = LoopController(loops=3, name='loop3') lc2 = LoopController(continue_forever=True) lc2.append(HttpRequest(host='www.google.com')) lc.append(HttpRequest(host='www.google.com')) lc.append(lc2) mc = ModuleController(node_path="NewTestPlan/Test Fragment/loop3") test_fragment.append(lc) test_fragment.append(mc) test_plan.append(test_fragment) open('example_testplan_01.jmx', 'w').write(test_plan.to_xml())