This commit is contained in:
Bernhard Posselt 2013-05-07 17:50:37 +02:00
Родитель e52e9332df
Коммит 6fa3308b9e
11 изменённых файлов: 282 добавлений и 3 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -3,7 +3,8 @@ coffee/build/
node_modules/
*.log
build/
js/*.xml
js/*.xml
.rvm
# just sane ignores
.*.sw[po]

Просмотреть файл

@ -1,4 +1,4 @@
# ownCloud - App Framework
# ownCloud - News
#
# @author Bernhard Posselt
# @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
@ -46,5 +46,5 @@ integration:
acceptance:
# TODO
cd tests/acceptance; make

Просмотреть файл

@ -131,3 +131,31 @@ in the **js/** directory
feedUpdateInterval: 1000*60*3 # miliseconds
Running tests
-------------
JavaScript
~~~~~~~~~~
For JavaScript tests see :file:`js/README.md`
PHP
~~~
All tests::
make test
Unit tests::
make unit
Integration tests::
make integration
.. note:: For acceptance tests, a user with the name **test** and password **test** must exist!
Acceptance tests::
make acceptance

7
tests/acceptance/Gemfile Normal file
Просмотреть файл

@ -0,0 +1,7 @@
source 'https://rubygems.org'
gem 'cucumber'
gem 'capybara'
gem 'selenium-webdriver'
gem 'headless'
gem 'rspec'

Просмотреть файл

@ -0,0 +1,55 @@
GEM
remote: https://rubygems.org/
specs:
builder (3.2.0)
capybara (2.1.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
cucumber (1.3.1)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12.0)
multi_json (~> 1.3)
diff-lcs (1.2.4)
ffi (1.8.1)
gherkin (2.12.0)
multi_json (~> 1.3)
headless (1.0.1)
mime-types (1.23)
multi_json (1.7.3)
nokogiri (1.5.9)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.1)
rubyzip (0.9.9)
selenium-webdriver (2.32.1)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
websocket (~> 1.0.4)
websocket (1.0.7)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
capybara
cucumber
headless
rspec
selenium-webdriver

30
tests/acceptance/Makefile Normal file
Просмотреть файл

@ -0,0 +1,30 @@
# ownCloud - News
#
# @author Bernhard Posselt
# @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
# License as published by the Free Software Foundation; either
# version 3 of the License, or any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
# This makefile is for general project specific stuff like packaging a new
# release for the app store and running php unittests which require core
bash=/bin/bash
all: acceptance
acceptance:
$(bash) run.sh
headless:
export HEADLESS=true && $(bash) run.sh

Просмотреть файл

@ -0,0 +1,25 @@
Given (/^I am logged in$/) do
# be sure to use the right browser session
Capybara.session_name = 'test'
# logout - just to be sure
visit '/index.php?logout=true'
visit '/'
fill_in 'user', with: 'test'
fill_in 'password', with: "test"
click_button 'submit'
#save_page
page.should have_selector('a#logout')
end
When (/^I am in the "([^"]*)" app$/) do |app|
visit "/index.php/apps/#{app}"
page.should have_selector('#logout')
end
When (/^I go to "([^"]*)"$/) do |path|
visit "#{path}"
page.should have_selector('#logout')
end

Просмотреть файл

@ -0,0 +1,24 @@
require 'bundler/setup'
require 'capybara/cucumber'
require 'selenium-webdriver'
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
Capybara.register_driver :selenium do |app|
http_client = Selenium::WebDriver::Remote::Http::Default.new
http_client.timeout = 200
Capybara::Selenium::Driver.new(app, :browser => :firefox, :http_client => http_client)
end
#
# app and app_host are set via command line parameter on cucumber call:
# cucumber HOST=33.33.33.10
#
host = ENV['HOST']
host ||= '33.33.33.10'
Capybara.app = host
Capybara.run_server = false
Capybara.app_host = "http://#{host}"
Capybara.default_selector = :css
Capybara.default_driver = :selenium

Просмотреть файл

@ -0,0 +1,34 @@
# only run when export HEADLESS=true
if ENV['HEADLESS'] == 'true'
require 'headless'
headless = Headless.new
headless.start
at_exit do
headless.destroy
end
Before do
#headless.video.start_capture
end
After do |scenario|
# for demo purpose: always record ;-)
#video= video_path(scenario)
#puts "Writing video to #{File.expand_path(video)}"
#headless.video.stop_and_save(video)
# if scenario.failed?
# headless.video.stop_and_save(video_path(scenario))
# else
# headless.video.stop_and_discard
# end
end
def video_path(scenario)
"#{scenario.name.split.join("_")}.mov"
end
end

1
tests/acceptance/logs/.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
*.json

74
tests/acceptance/run.sh Normal file
Просмотреть файл

@ -0,0 +1,74 @@
# ownCloud - News
#
# @author Bernhard Posselt, Thomas Müller, Jakob Sack
# @copyright 2013 Bernhard Posselt nukeawhale@gmail.com
# @copyright 2012-2013 Thomas Müller thomas.mueller@tmit.eu
# @copyright 2012-2013 Jakob Sack
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
# License as published by the Free Software Foundation; either
# version 3 of the License, or any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
# set up rvm and xvfb dependencies
if [[ ! -e "/usr/bin/xvfb-run" ]]; then
# archlinux
if [[ -e "/usr/bin/pacman" ]]; then
echo "installing xvfb, please enter password..."
sudo pacman -S xorg-server-xvfb
# fedora
elif [[ -e "/usr/bin/yum" ]]; then
echo "installing xvfb, please enter password..."
yum install xorg-x11-server-Xvfb
# debian
elif [[ -e "/usr/bin/apt-get" ]]; then
echo "installing xvfb, please enter password..."
sudo apt-get install xvfb
else
echo "You have to install xvfb in order to run the test suite"
exit 1
fi
fi
# dont use --user-install for gems since this breaks rvm. abort setup in case it
# exists
if [[ -e "/etc/gemrc" ]]; then
if grep -qe "^[^#].*user-install" /etc/gemrc; then
echo "Found --user-install in /etc/gemrc"
echo "Please remove it, as it will break rubygems in RVM."
exit 1
fi
fi
# set up rvm
if [[ -f "$HOME/.rvm/scripts/rvm" ]]; then
source "$HOME/.rvm/scripts/rvm"
elif [[ -f "/usr/local/rvm/scripts/rvm" ]]; then
source "/usr/local/rvm/scripts/rvm"
else
# set up a local rvm installation
curl -L get.rvm.io | bash -s stable
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
fi
# Set the gemset and ruby version
rvm install 2.0.0
rvm use ruby-2.0.0@oc_acceptance --create
bundle install
cucumber -f json -o ./logs/owncloud.json -f pretty HOST=localhost/owncloud features