[Pkg-owncloud-commits] [owncloud-doc] 48/71: Coding guidelines section about unit tests

David Prévot taffit at moszumanska.debian.org
Tue Dec 2 22:02:55 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud-doc.

commit ba7a9149be1e29d2c2bef0f9eb656152cc7081c4
Author: Joas Schilling <nickvergessen at gmx.de>
Date:   Fri Nov 21 11:09:48 2014 +0100

    Coding guidelines section about unit tests
---
 developer_manual/general/codingguidelines.rst | 28 +++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/developer_manual/general/codingguidelines.rst b/developer_manual/general/codingguidelines.rst
index 7b73d9a..7cf9048 100644
--- a/developer_manual/general/codingguidelines.rst
+++ b/developer_manual/general/codingguidelines.rst
@@ -165,6 +165,34 @@ Control Structures
 
   ?>
 
+Unit tests
+^^^^^^^^^^
+Unit tests must always extend the ``\Test\TestCase`` class, which takes care
+of cleaning up the installation after the test.
+
+If a test is run with multiple different values, a data provider must be used.
+The name of the data provider method must not start with ``test`` and must end
+with ``Data``.
+
+.. code-block:: php
+
+    <?php
+    namespace Test;
+    class Dummy extends \Test\TestCase {
+        public function dummyData() {
+            return array(
+                array(1, true),
+                array(2, false),
+            );
+        }
+
+        /**
+         * @dataProvider dummyData
+         */
+        public function testDummy($input, $expected) {
+            $this->assertEquals($expected, \Dummy::method($input));
+        }
+    }
 
 
 JavaScript

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-doc.git



More information about the Pkg-owncloud-commits mailing list