-
Notifications
You must be signed in to change notification settings - Fork 1
Basic skeleton with tests #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
95a93b1
7a12be2
7af829d
07019b9
a27f0c9
90896e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| .idea | ||
| bin | ||
| vendor | ||
| composer.lock | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <?php | ||
|
|
||
| use QATools\BehatExtension\Context\QAToolsContext; | ||
|
|
||
| class MainContext extends QAToolsContext | ||
| { | ||
|
|
||
| /** | ||
| * @When /^the user enters (.+?) and (.+?)$/ | ||
| */ | ||
| public function fillForm($username, $password) | ||
| { | ||
| $this->page->fillForm($username, $password); | ||
| } | ||
|
|
||
| /** | ||
| * @Then /^the login should fail$/ | ||
| */ | ||
| public function loginFail() | ||
| { | ||
| $this->page = $this->page->loginFailure(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's incorrect approach. Page provides method to interact with elements on a page. It doesn't have methods, that would deliberately fill the form with data, that will lead to failure/success to allow tests to use them.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case always combine submit and filling the form? I always divided that but it could also be one step after all.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method on PageObject/element class represents complete action from UI/user viewpoint. User sees login process as single action: fill fields + press ENTER/login button. This way the PageObject should do it in same fashion. |
||
| } | ||
|
|
||
| /** | ||
| * @Then /^the login should succeed/ | ||
| */ | ||
| public function loginSucceed() | ||
| { | ||
| $this->page = $this->page->loginSuccess(); | ||
| } | ||
|
|
||
| /** | ||
| * @Given /^the user waits for ([0-9]+) seconds$/ | ||
| */ | ||
| public function waitFor($seconds) | ||
| { | ||
| sleep($seconds); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Feature: Login | ||
| In order to use the website site | ||
| As a website user | ||
| I need to login successfully | ||
|
|
||
| @javascript @login @failing-login | ||
| Scenario: Failing login due wrong password | ||
| Given the user visits the "Login Page" | ||
| When the user enters user and invalidpassword | ||
| And the login should fail | ||
|
|
||
| @javascript @login @successful-login | ||
| Scenario: Successful login of user | ||
| Given the user visits the "Login Page" | ||
| When the user enters user and validpassword | ||
| And the login should succeed |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <html> | ||
| <head> | ||
| <!-- Latest compiled and minified CSS --> | ||
| <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> | ||
| <!-- Optional theme --> | ||
| <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> | ||
| <!-- additional css --> | ||
| <link rel="stylesheet" href="additional.css"> | ||
| <!-- Latest compiled and minified JavaScript --> | ||
| <script src="//code.jquery.com/jquery-1.11.2.min.js"></script> | ||
| <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> | ||
| </head> | ||
| <body> | ||
| <div class="row"> | ||
| <div class="col-md-5 col-md-offset-1"> | ||
| <h3>Caption Column 1</h3> | ||
| Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore | ||
| magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd | ||
| gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing | ||
| elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero | ||
| eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum | ||
| dolor sit amet. | ||
| </div> | ||
| <div class="col-md-5"> | ||
| <h3>Caption Column 2</h3> | ||
| Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore | ||
| magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd | ||
| gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing | ||
| elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero | ||
| eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum | ||
| dolor sit amet. | ||
| </div> | ||
| </div> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .margin-top { | ||
| margin-top: 20px; | ||
| } | ||
|
|
||
| .margin-bottom { | ||
| margin-bottom: 20px; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <html> | ||
| <head> | ||
| <!-- Latest compiled and minified CSS --> | ||
| <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> | ||
| <!-- Optional theme --> | ||
| <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> | ||
| <!-- additional css --> | ||
| <link rel="stylesheet" href="additional.css"> | ||
| <!-- Latest compiled and minified JavaScript --> | ||
| <script src="//code.jquery.com/jquery-1.11.2.min.js"></script> | ||
| <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> | ||
| </head> | ||
| <body> | ||
| <div class="row margin-top margin-bottom"> | ||
| <form id="login-form" role="form" class="col-md-4 col-md-offset-4 panel panel-default" action="login.php" method="POST"> | ||
| <div class="panel-body"> | ||
| <div class="form-group"> | ||
| <label for="username">Username</label> | ||
| <input type="text" class="form-control" name="username" id="username"> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="password">Password</label> | ||
| <input type="password" class="form-control" name="password" id="password"> | ||
| </div> | ||
| <input type="submit" class="btn btn-default" value="Login"> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| <hr> | ||
| <div class="row"> | ||
| <div class="col-md-5 col-md-offset-1"> | ||
| <h3>Caption Column 1</h3> | ||
| Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore | ||
| magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd | ||
| gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing | ||
| elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero | ||
| eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum | ||
| dolor sit amet. | ||
| </div> | ||
| <div class="col-md-5"> | ||
| <h3>Caption Column 2</h3> | ||
| Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore | ||
| magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd | ||
| gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing | ||
| elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero | ||
| eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum | ||
| dolor sit amet. | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
| /** | ||
| * This file is part of the QA-Tools library. | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| * | ||
| * @copyright Michael Iwersen <mi.iwersen@gmail.com> | ||
| * @link https://github.com/qa-tools/behat-example | ||
| */ | ||
|
|
||
| if ( empty($_POST) ) { | ||
| header('Location: index.html'); | ||
| } | ||
|
|
||
| if ( $_POST['username'] != 'user' ) { | ||
| header('Location: index.html'); | ||
| } | ||
|
|
||
| if ( $_POST['password'] != 'validpassword' ) { | ||
| header('Location: index.html'); | ||
| } | ||
|
|
||
| header('Location: account.html'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| default: | ||
| suites: | ||
| standard: | ||
| paths: ['Features'] | ||
| contexts: [MainContext] | ||
|
|
||
| extensions: | ||
| Behat\MinkExtension: | ||
| default_session: selenium2 | ||
| javascript_session: selenium2 | ||
| base_url: 'http://behat-example.qa-tools.io' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should use Also in README.md I recommend mentioning steps required to make example operational, like go and replace |
||
|
|
||
| selenium2: ~ | ||
|
|
||
| QATools\BehatExtension: | ||
| qa_tools: | ||
| base_url: 'http://behat-example.qa-tools.io' | ||
| page_namespace_prefix: ['\QATools\Example\Pages'] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "name": "qa-tools/behat-example", | ||
| "license": "BSD-3-Clause", | ||
| "require": { | ||
| "php": ">=5.3.1", | ||
| "qa-tools/qa-tools": "~1.0@dev", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use stable versions, where you can. |
||
| "qa-tools/behat-extension": "dev-cleanup", | ||
| "mindplay/annotations": "~1.2@dev", | ||
| "behat/mink": "~1.5@dev", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mink isn't needed for this extension to operate, it's
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be even in cause the all dependencies should be resolved through the extension itself.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. I recommend using example itself to create new project and see what will happen.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, locally. Set to stable and
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dev-* isn't not stable, but direct reference to branch. What I meant is to use say ~1.0 as qa-tools version and so on. |
||
| "behat/mink-extension": "*@dev", | ||
| "behat/mink-selenium2-driver": "~1.1@dev" | ||
| }, | ||
| "repositories": [ | ||
| { | ||
| "type": "vcs", | ||
| "url": "/Users/michi/Documents/Workspace/behat-extension" | ||
| } | ||
| ], | ||
| "autoload-dev": { | ||
| "psr-0": { | ||
| "QATools\\Example": "./src" | ||
| } | ||
| }, | ||
| "config": { | ||
| "bin-dir": "bin/" | ||
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why you've changed file attributes from Unix ones to Windows ones (644 > 755).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault, configured the web server and executed chmod through my link. I can switch that back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting why you've put
composer.lockin the.gitignoreand committed it as well?