jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1816323 - in /jmeter/trunk/test/src/org/apache/jmeter/report/processor: Top5ErrorsBySamplerConsumerSpec.groovy Top5ErrorsSummaryDataSpec.groovy
Date Sat, 25 Nov 2017 17:02:44 GMT
Author: fschumacher
Date: Sat Nov 25 17:02:44 2017
New Revision: 1816323

URL: http://svn.apache.org/viewvc?rev=1816323&view=rev
Log:
More unit tests from pr #332 from github

Contributed by Graham Russell

Added:
    jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsBySamplerConsumerSpec.groovy
  (with props)
    jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsSummaryDataSpec.groovy
  (with props)

Added: jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsBySamplerConsumerSpec.groovy
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsBySamplerConsumerSpec.groovy?rev=1816323&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsBySamplerConsumerSpec.groovy
(added)
+++ jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsBySamplerConsumerSpec.groovy
Sat Nov 25 17:02:44 2017
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.report.processor
+
+import org.apache.jmeter.junit.spock.JMeterSpec
+import org.apache.jmeter.report.core.Sample
+
+class Top5ErrorsBySamplerConsumerSpec extends JMeterSpec {
+
+    def sut = new Top5ErrorsBySamplerConsumer()
+
+    def "summary info data updated with non-controller passing sample"() {
+        given:
+            def mockSummaryInfo = Mock(AbstractSummaryConsumer.SummaryInfo)
+            def mockSample = Mock(Sample) {
+                getSuccess() >> true
+            }
+        when:
+            sut.updateData(mockSummaryInfo, mockSample)
+        then:
+            def data = (Top5ErrorsSummaryData) mockSummaryInfo.getData()
+            data.getTotal() == 1
+    }
+
+    def "summary info data updated with non-controller failing sample"() {
+        given:
+            def mockSummaryInfo = Mock(AbstractSummaryConsumer.SummaryInfo)
+            def mockSample = Mock(Sample) {
+                getResponseCode() >> "200"
+            }
+        when:
+            sut.updateData(mockSummaryInfo, mockSample)
+        then:
+            def data = (Top5ErrorsSummaryData) mockSummaryInfo.getData()
+            data.getTotal() == 1
+            data.getErrors() == 1
+            data.top5ErrorsMetrics[0][0] == ErrorsSummaryConsumer.ASSERTION_FAILED
+            def overallData = (Top5ErrorsSummaryData) sut.getOverallInfo().getData()
+            overallData.getTotal() == 1
+            overallData.getErrors() == 1
+            overallData.top5ErrorsMetrics[0][0] == ErrorsSummaryConsumer.ASSERTION_FAILED
+    }
+
+    def "key from sample is name"() {
+        given:
+            def mockSample = Mock(Sample)
+        when:
+            def key = sut.getKeyFromSample(mockSample)
+        then:
+            1 * mockSample.getName() >> "name"
+            key == "name"
+    }
+
+    def "there are 3 + 2n expected results title columns"() {
+        expect:
+            sut.createResultTitles().size ==
+                    3 + 2 * sut.MAX_NUMBER_OF_ERRORS_IN_TOP
+
+    }
+
+}

Propchange: jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsBySamplerConsumerSpec.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsSummaryDataSpec.groovy
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsSummaryDataSpec.groovy?rev=1816323&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsSummaryDataSpec.groovy
(added)
+++ jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsSummaryDataSpec.groovy
Sat Nov 25 17:02:44 2017
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.report.processor
+
+import spock.lang.Specification
+
+class Top5ErrorsSummaryDataSpec extends Specification {
+
+    def sut = new Top5ErrorsSummaryData()
+
+    def "when no errors are registered an array with null values is returned"() {
+        expect:
+            sut.getTop5ErrorsMetrics() == new Object[5][2]
+    }
+
+    def "error messages with the same frequency are preserved up until the size limit"()
{
+        given:
+            ["A", "B", "C", "D", "E", "F"].each { sut.registerError(it) }
+        expect:
+            sut.getTop5ErrorsMetrics() == [["A", 1], ["B", 1], ["C", 1], ["D", 1], ["E",
1]]
+    }
+
+    def "error messages are sorted by size, descending"() {
+        given:
+            ["A", "A", "A", "B", "B", "C"].each {
+                sut.registerError(it)
+            }
+        expect:
+            sut.getTop5ErrorsMetrics() == [["A", 3], ["B", 2], ["C", 1], [null, null], [null,
null]]
+    }
+
+    def "error and total count start at 0"() {
+        expect:
+            sut.getErrors() == 0
+            sut.getTotal() == 0
+    }
+
+    def "error and total count increment by one each time"() {
+        when:
+            sut.incErrors()
+            sut.incTotal()
+        then:
+            sut.getErrors() == 1
+            sut.getTotal() == 1
+    }
+
+}

Propchange: jmeter/trunk/test/src/org/apache/jmeter/report/processor/Top5ErrorsSummaryDataSpec.groovy
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message