如何在ruby-jmeter中创建响应断言

时间:2015-04-10 14:25:10

标签: ruby-on-rails ruby jmeter ruby-jmeter

我正在使用ruby-jmeter来创建jmeter计划。到目前为止,我已经在https://github.com/flood-io/ruby-jmeter/blob/master/lib/ruby-jmeter/DSL.md

处找到了各种DSL

但我不明白如何使用响应断言DSL。 https://github.com/flood-io/ruby-jmeter/blob/master/lib/ruby-jmeter/dsl/response_assertion.rb

def initialize(params={})
      testname = params.kind_of?(Array) ? 'ResponseAssertion' : (params[:name] || 'ResponseAssertion')
      @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
<ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="#{testname}" enabled="true">
  <collectionProp name="Asserion.test_strings">
    <stringProp name="0"/>
  </collectionProp>
  <stringProp name="Assertion.test_field">Assertion.response_data</stringProp>
  <boolProp name="Assertion.assume_success">false</boolProp>
  <intProp name="Assertion.test_type">16</intProp>
  <stringProp name="Assertion.scope">all</stringProp>
</ResponseAssertion>)
      EOS
      update params
      update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
    end

我该如何使用它?

对于csv_data_set_config,

DLS就像

def initialize(params={})
      testname = params.kind_of?(Array) ? 'CsvDataSetConfig' : (params[:name] || 'CsvDataSetConfig')
      @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
<CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="#{testname}" enabled="true">
  <stringProp name="delimiter">,</stringProp>
  <stringProp name="fileEncoding"/>
  <stringProp name="filename"/>
  <boolProp name="quotedData">false</boolProp>
  <boolProp name="recycle">true</boolProp>
  <stringProp name="shareMode">shareMode.all</stringProp>
  <boolProp name="stopThread">false</boolProp>
  <stringProp name="variableNames"/>
</CSVDataSet>)
      EOS
      update params
      update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
    end

我用它像

csv_data_set_config filename: "/Users/ajinkya41/projects/scout_tools/users.csv", variableNames: "username,password"

使用起来很简单,但这种反应断言对我来说有点困难。

1 个答案:

答案 0 :(得分:3)

有一个基本的例子using response assertions here等等。

angular.module('studentList',[]);
app.service('studentData',['$http',function($http){
    return $http.get('http://purplenimbus.net/edu/students.php')
        .success(function(data){
            return data;
        })
        .error(function(err){
            return err;
        });
}]);

app.controller('studentsController', ['$scope','studentData',function($scope,studentData){
    $scope.title = 'Student List';
    studentData.success(function(data){
       $scope.list = data;
    });
}]);

app.directive('students', function(){
    return {
        restrict: 'E',
        templateUrl:'student.html'
    };
});