2012-01-06 6 views
9

मैं अपने आईओएस एप्लिकेशन का परीक्षण करने के लिए यूआईयूटोमेशन स्क्रिप्ट का उपयोग कर रहा हूं। मैंने कमांड लाइन से चल रही स्क्रिप्ट प्राप्त करने में कामयाब रहा है, लेकिन अब मुझे आउटपुट (पास/असफल) को उस प्रारूप में रूपांतरित करने की ज़रूरत है, जिसे जेनकिंस समझ सकते हैं, आदर्श रूप से जुनीट शैली।मैं जेनकिन्स के लिए जुनीट शैली आउटपुट में अपने आईओएस यूआईयूयूटोमेशन परीक्षण के आउटपुट को कैसे बदल सकता हूं?

क्या किसी ने & लिखने से पहले किसी को भी ऐसा करने के लिए कोई स्क्रिप्ट लिखी है?

बहुत धन्यवाद

+0

यहां तक ​​कि मैं भी वही कोशिश कर रहा हूं। क्या आपने जेनकींस के माध्यम से सभी चरणों को एक साथ एकीकृत किया है .. कोड चेकइन -> बिल्ड -> अपनी परमाणु स्क्रिप्ट चला रहा है -> इसे से परीक्षा परिणाम प्राप्त करना कृपया मुझे बताएं कि क्या आपने – vikas

+0

से ऊपर की कोशिश की है, मैंने बड़े पैमाने पर खोज की है, और ' टी कुछ भी मिला। हमारे पास अपने उद्देश्यों के लिए कुछ हैक किया गया है। कृपया कुछ पुन: उपयोग करने योग्य बनाएं। मैं इसका इस्तेमाल करूंगा। –

+0

क्या इसका मतलब है "इसे एक प्रारूप जेनकिन्स समझ में परिवर्तित करें"? यदि आप जेनकींस को सिर्फ यह बताने के लिए चाहते हैं कि परीक्षण परीक्षण के अनुसार पास या विफल हुआ है, तो इसे एक शेल स्क्रिप्ट में पार्स करके इसे एक बिल्ड चरण के रूप में चलाया जा सकता है। अन्यथा, यदि आप जेनकींस रिपोर्ट प्रकाशन क्षमताओं का उपयोग करना चाहते हैं और अंत में एक अच्छी रिपोर्ट प्राप्त करना है तो आपको इसे जूनिट एक्सएमएल शैली में परिवर्तित करना होगा, मुझे लगता है कि यह एकमात्र चीज जेनकिंस जानता है कि – Michael

उत्तर

3

शायद तुम पर एक नजर है कर सकते हैं: https://github.com/shaune/jasmine-ios-acceptance-tests

संपादित करें: मैं भी चमेली का उपयोग करने से परहेज किया है। करने के लिए 'सुनने' शुरू करते हैं, गुजरती हैं और असफल परीक्षण, मैं बस से बदल दिया है UIALogger.logStart, UIALogger.logFail और UIALogger.logPass:

(function() { 
    // An anonymous function wrapper helps you keep oldSomeFunction private  
    var oldSomeFunction = UIALogger.logStart; 
    UIALogger.logStart = function() { 
    //UIALogger.logDebug("intercepted a logStart : " + arguments); 
    OKJunitLogger.reportTestSuiteStarting(arguments[0]); 
    oldSomeFunction.apply(this, arguments); 
    } 
})(); 
+0

को कैसे पार्स करना है हाय यह बहुत अच्छा लग रहा है लेकिन मैं कोशिश कर रहा था जैस्मीन का उपयोग करने से बचने के लिए और चीजों को सरल रखने के लिए [tuneup.js] (https://github.com/alexvollmer/tuneup_js) लाइब्रेरी का उपयोग करें। मैंने आपके उत्तर को सही के रूप में चिह्नित किया है क्योंकि यह मेरी आवश्यकता को पूरा करता है, धन्यवाद। – MandyW

+0

मैंने आपके जवाब को संपादित करने के लिए सिर्फ –

+0

@kenji को लागू करने के लिए चुना गया समाधान दिखाया है क्या आप इस समारोह का उपयोग कैसे और कहां कर सकते हैं इस पर थोड़ा सा समझा सकते हैं? – stackErr

1

मैं bealive आप आप यहाँ क्या जरूरत मिल जाएगा: https://github.com/shinetech/jenkins-ios-example

क्या आप रुचि हो में स्क्रिप्ट कॉल "ocunit2junit.rb"

मैंने इसे एक प्रोजेक्ट के लिए उपयोग किया, यह बहुत अच्छा काम करता है।

#!/usr/bin/ruby 
# 
# ocunit2junit.rb was written by Christian Hedin <[email protected]> 
# Version: 0.1 - 30/01 2010 
# Usage: 
# xcodebuild -yoursettings | ocunit2junit.rb 
# All output is just passed through to stdout so you don't miss a thing! 
# JUnit style XML-report are put in the folder specified below. 
# 
# Known problems: 
# * "Errors" are not cought, only "warnings". 
# * It's not possible to click links to failed test in Hudson 
# * It's not possible to browse the source code in Hudson 
# 
# Acknowledgement: 
# Big thanks to Steen Lehmann for prettifying this script. 
################################################################ 
# Edit these variables to match your system 
# 
# 
# Where to put the XML-files from your unit tests 
TEST_REPORTS_FOLDER = "test-reports" 
# 
# 
# Don't edit below this line 
################################################################ 

require 'time' 
require 'FileUtils' 
require 'socket' 

class ReportParser 

    attr_reader :exit_code 

    def initialize(piped_input) 
    @piped_input = piped_input 
    @exit_code = 0 

    FileUtils.rm_rf(TEST_REPORTS_FOLDER) 
    FileUtils.mkdir(TEST_REPORTS_FOLDER) 
    parse_input 
    end 

    private 

    def parse_input 
    @piped_input.each do |piped_row| 
     puts piped_row 
     case piped_row 

     when /Test Suite '(\S+)'.*started at\s+(.*)/ 
      t = Time.parse($2.to_s) 
      handle_start_test_suite(t) 

     when /Test Suite '(\S+)'.*finished at\s+(.*)./ 
      t = Time.parse($2.to_s) 
      handle_end_test_suite($1,t)  

     when /Test Case '-\[\S+\s+(\S+)\]' started./ 
      test_case = $1 

     when /Test Case '-\[\S+\s+(\S+)\]' passed \((.*) seconds\)/ 
      test_case = $1 
      test_case_duration = $2.to_f 
      handle_test_passed(test_case,test_case_duration) 

     when /(.*): error: -\[(\S+) (\S+)\] : (.*)/ 
      error_location = $1 
      test_suite = $2 
      test_case = $3 
      error_message = $4 
      handle_test_error(test_suite,test_case,error_message,error_location) 

     when /Test Case '-\[\S+ (\S+)\]' failed \((\S+) seconds\)/ 
      test_case = $1 
      test_case_duration = $2.to_f 
      handle_test_failed(test_case,test_case_duration) 

     when /failed with exit code (\d+)/ 
      @exit_code = $1.to_i 

     when 
      /BUILD FAILED/ 
      @exit_code = -1; 
     end 
    end 
    end 

    def handle_start_test_suite(start_time) 
    @total_failed_test_cases = 0 
    @total_passed_test_cases = 0 
    @tests_results = Hash.new # test_case -> duration 
    @errors = Hash.new # test_case -> error_msg 
    @ended_current_test_suite = false 
    @cur_start_time = start_time 
    end 

    def handle_end_test_suite(test_name,end_time) 
    unless @ended_current_test_suite 
     current_file = File.open("#{TEST_REPORTS_FOLDER}/TEST-#{test_name}.xml", 'w') 
     host_name = string_to_xml Socket.gethostname 
     test_name = string_to_xml test_name 
     test_duration = (end_time - @cur_start_time).to_s 
     total_tests = @total_failed_test_cases + @total_passed_test_cases 
     suite_info = '<testsuite errors="0" failures="'[email protected]_failed_test_cases.to_s+'" hostname="'+host_name+'" name="'+test_name+'" tests="'+total_tests.to_s+'" time="'+test_duration.to_s+'" timestamp="'+end_time.to_s+'">' 
     current_file << "<?xml version='1.0' encoding='UTF-8' ?>\n" 
     current_file << suite_info 
     @tests_results.each do |t| 
     test_case = string_to_xml t[0] 
     duration = @tests_results[test_case] 
     current_file << "<testcase classname='#{test_name}' name='#{test_case}' time='#{duration.to_s}'" 
     unless @errors[test_case].nil? 
      # uh oh we got a failure 
      puts "tests_errors[0]" 
      puts @errors[test_case][0] 
      puts "tests_errors[1]" 
      puts @errors[test_case][1] 

      message = string_to_xml @errors[test_case][0].to_s 
      location = string_to_xml @errors[test_case][1].to_s 
      current_file << ">\n" 
      current_file << "<failure message='#{message}' type='Failure'>#{location}</failure>\n" 
      current_file << "</testcase>\n" 
     else 
      current_file << " />\n" 
     end 
     end 
     current_file << "</testsuite>\n" 
     current_file.close 
     @ended_current_test_suite = true 
    end 
    end 

    def string_to_xml(s) 
    s.gsub(/&/, '&amp;').gsub(/'/, '&quot;').gsub(/</, '&lt;') 
    end 

    def handle_test_passed(test_case,test_case_duration) 
    @total_passed_test_cases += 1 
    @tests_results[test_case] = test_case_duration 
    end 

    def handle_test_error(test_suite,test_case,error_message,error_location) 
# error_message.tr!('<','').tr!('>','') 
    @errors[test_case] = [ error_message, error_location ] 
    end 

    def handle_test_failed(test_case,test_case_duration) 
    @total_failed_test_cases +=1 
    @tests_results[test_case] = test_case_duration 
    end 

end 

#Main 
#piped_input = File.open("tests_fail.txt") # for debugging this script 
piped_input = ARGF.read 

report = ReportParser.new(piped_input) 

exit report.exit_code 
+0

HI मार्टिन, मैं अपने ओसीयूनीट परीक्षणों के लिए इसका उपयोग कर रहा हूं लेकिन मेरा प्रश्न यूआई परीक्षण से संबंधित है जिसके लिए मैं ऐप्पल के यूआई ऑटोमेशन इंस्ट्रूमेंट का उपयोग कर रहा हूं। ये परीक्षण जावास्क्रिप्ट में लिखे गए हैं और एक्सएमएल आउटपुट उत्पन्न करते हैं। – MandyW

+0

@MandyW hooo, मुझे खेद है कि मुझे आपका प्रश्न ठीक से नहीं मिला।मेरे द्वारा प्रदान किया गया कोड जेनकिन्स/हडसन में ओआईयूयूटीमेशन स्क्रिप्ट आउटपुट को बदलने के लिए जेनकिंस/हडसन में ओसीयूनीट परीक्षणों को बदलने के लिए है। वैसे भी मुझे आशा है कि आपको –

1

शायद आप this का उपयोग कर सकते हैं।

और जेनकींस में खोल निष्पादित करें:

sh setup.sh sh runTests.sh ./sample/alltests.js "/Users/komejun/Library/Application Support/iPhone Simulator/5.0/Applications/1622F505-8C07-47E0-B0F0-3A125A88B329/Recipes.app/" 

और रिपोर्ट ./ynmsk-report/test.xml

+0

हाय मिलेगा, यह लिंक 404 पर जाता है .. – MandyW

+0

@MandyW पता cheanged.https: //github.com/douban/ynm3k। – houlianpi

0

में स्वतः निर्मित हो जाएगा आप tuneupjs लाइब्रेरी का उपयोग कर सकते हैं। पुस्तकालय परीक्षण धावक प्रदान करता है जो एक एक्सएमएल रिपोर्ट उत्पन्न करता है (जुनीट शैली)। यह एक्सकोड 6 के साथ काम करता है। एक्सएमएल रिपोर्ट के लिए बस -x param प्रदान करें। इसे यहां देखें: http://www.tuneupjs.org/running.html

संबंधित मुद्दे

 संबंधित मुद्दे