Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
7fef889f
Commit
7fef889f
authored
8 years ago
by
Jaime Perez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Be a bit more verbose with the testing instructions.
parent
4a0edb27
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
TESTING.md
+48
-19
48 additions, 19 deletions
TESTING.md
with
48 additions
and
19 deletions
TESTING.md
+
48
−
19
View file @
7fef889f
Testing
Testing
=======
=======
All tests should be in "tests/". The directory structure there replicates the
Testing your code is crucial to have a stable and good quality product.
main structure of the code. Each class Whatever is tested by a class named
We are therefore slowly increasing the amount of tests we perform, and
WhateverTest.php, following the same path as the original.
as a rule of thumb
**all new code should have associated tests**
. If you
want to contribute to the project with a pull request, make sure to
**include tests covering your code**
. We won't accept pull requests
without tests or getting the code coverage down, except in very specific
situations.
The test classes (WhateverTest) need to extend PHPUnit_Framework_TestCase, and
All the tests reside in the
`tests`
directory. The directory structure
inside you can implement how many methods you want. phpunit will only run the
there replicates the main structure of the code. Each class is tested by
ones prefixed with "test".
a class named with the same name and
`Test`
appended, having the same
directory structure as the original, but inside the
`tests`
directory.
We also use namespaces, with
`SimpleSAML\Test`
as the root for standard
classes, and
`SimpleSAML\Test\Module\modulename`
for classes located in
modules.
You'd usually use the $this->assertSomething() methods provided by
For example, if you want to test the
`SimpleSAML\Utils\HTTP`
class
PHPUnit_Framework_TestCase, but you can also tell phpunit to expect an
located in
`lib/SimpleSAML/Utils/HTTP.php`
, the tests must be in a class
exception to be thrown using phpdoc:
named
`HTTPTest`
implemented in
`tests/lib/SimpleSAML/Utils/HTTPTest.php`
, with the following namespace
definition:
```
php
namespace
SimpleSAML\Test\Utils
;
```
```
/**
The test classes need to extend
`PHPUnit_Framework_TestCase`
, and inside
you can implement as many methods as you want.
`phpunit`
will only run
the ones prefixed with "test".
You will usually make use of the
`assert*()`
methods provided by
`PHPUnit_Framework_TestCase`
, but you can also tell
`phpunit`
to expect
an exception to be thrown using
*phpdoc*
. For example, if you want to
ensure that the
`SimpleSAML\Utils\HTTP::addURLParameters()`
method
throws an exception in a specific situation:
```
php
/**
* Test SimpleSAML\Utils\HTTP::addURLParameters().
* Test SimpleSAML\Utils\HTTP::addURLParameters().
*
*
* @expectedException \InvalidArgumentException
* @expectedException \InvalidArgumentException
*/
*/
public
function
testAddURLParametersInvalidParameters
()
{
```
```
Run the tests locally by hiding the config-directory in the root (as the tests cannot use that) and running:
Refer to
[
the `phpunit` documentation
](
https://phpunit.de/documentation.html
)
for more information on how to write tests.
```
Once you have implemented your tests, you can run them locally. First,
make sure the
`config`
directory is
**not**
in the root of your
SimpleSAMLphp installation, as the tests cannot use that. Make sure
you have
`phpunit`
installed and run:
```
sh
phpunit
-c
tools/phpunit/phpunit.xml
phpunit
-c
tools/phpunit/phpunit.xml
```
```
After you've pushed a change, Travis-CI will run your test in the CI platform.
All the tests are run by our
*continuous integration*
platform,
[
travis
](
https://travis-ci.org/simplesamlphp/simplesamlphp
)
. If you are
Todo
submitting a pull request, Travis will run your tests and notify whether
----
your code builds or not according to them.
The tests should use namespaces.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment