2011-07-20 15 views
6

के साथ तैनाती पर स्वचालित रूप से परीक्षण चलाएं क्या मेरे पास cap deploy चलाते समय कैपिस्ट्रानो रन यूनिट परीक्षण करने का कोई तरीका है, और अगर वे पास नहीं होते हैं तो विफल हो जाते हैं? मुझे पता है कि यह नियोक्ता द्वारा किया जा सकता है और किया जाना चाहिए, लेकिन मैं इसे स्वचालित होने के लिए प्यार करता हूँ। किसी भी विचार की बहुत प्रशंसा की जाएगी।कैपिस्ट्रानो

अग्रिम धन्यवाद!

संपादित करें: मैं समाधान के रूप में this का उपयोग कर समाप्त हुआ।

उत्तर

4

यह Capistrano कार्य सर्वर पर इकाई परीक्षण चलेगा उत्पादन मोड में स्थापित किया जा रहा,:

desc "Run the full tests on the deployed app." 
task :run_tests do 
run "cd #{release_path} && RAILS_ENV=production rake && cat /dev/null > log/test.log" 
end 

मिले यहाँ समाधान: http://marklunds.com/articles/one/338

: डी

+0

समाधान आप पोस्ट के साथ उत्पादन सर्वर पर परीक्षण चलाता है। मुझे नहीं लगता कि बहुमत कर रहे हैं .. – brayne

+2

मैंने अपनी deploy.rb फ़ाइल में [यह] (https://gist.github.com/1097695) जोड़ना समाप्त कर दिया। – Ian

1

इस सेटअप चलेंगे अपने तैनाती से पहले स्थानीय रूप से परीक्षण करता है।

कैपिस्ट्रानो कार्य, उदा। lib/Capistrano/कार्य/deploy.rake

namespace :deploy do 
    desc 'Run test suite before deployment' 
    task :test_suite do 
    run_locally do 
     execute :rake, 'test' 
    end 
    end 
end 

Capistrano config,config/deploy.rb

before 'deploy:starting', 'deploy:test_suite' 

Capistrano v3.x में काम करता

0

config/deploy.rb

# Path of tests to be run, use array with empty string to run all tests 
set :tests, [''] 

namespace :deploy do 
    desc "Runs test before deploying, can't deploy unless they pass" 
    task :run_tests do 
    test_log = "log/capistrano.test.log" 
    tests = fetch(:tests) 
    tests.each do |test| 
     puts "--> Running tests: '#{test}', please wait ..." 
     unless system "bundle exec rspeC#{test} > #{test_log} 2>&1" 
     puts "--> Aborting deployment! One or more tests in '#{test}' failed. Results in: #{test_log}" 
     exit; 
     end 
     puts "--> '#{test}' passed" 
    end 
    puts "--> All tests passed, continuing deployment" 
    system "rm #{test_log}" 
    end 

    # Only allow a deploy with passing tests to be deployed 
    before :deploy, "deploy:run_tests" 

end 

भागो इसके साथ

cap production deploy:run_tests 
संबंधित मुद्दे