doc:articles:writing-tests

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

doc:articles:writing-tests [2008/04/10 22:27]
philip initial commit, moved from old wiki, written by nuno and philip
doc:articles:writing-tests [2008/04/10 22:58]
felipe Reformatting text
Line 1: Line 1:
 Part of an upcoming php.net article titled "How can you help PHP.NET today?"​ with this part focusing on writing tests. It's essentially in a FAQ format: Part of an upcoming php.net article titled "How can you help PHP.NET today?"​ with this part focusing on writing tests. It's essentially in a FAQ format:
  
-Why should I write a test? +===== Why should I write a test? =====
 Code coverage is important for the success of any project including PHP. When code coverage reaches 100%, it'll mean that every piece of code within the PHP sources will be executed while running the tests. This helps determine if behaviour changes so essentially it helps prevent bugs from being introduced into PHP. Code coverage is important for the success of any project including PHP. When code coverage reaches 100%, it'll mean that every piece of code within the PHP sources will be executed while running the tests. This helps determine if behaviour changes so essentially it helps prevent bugs from being introduced into PHP.
  
-What kind of setup do I need to write good tests? +===== What kind of setup do I need to write good tests? ​=====
 gcc >= 3.4 with gcov. gcc >= 3.4 with gcov.
 Your local setup should also include lcov that is available here: Your local setup should also include lcov that is available here:
Line 23: Line 21:
 In summary: Install lcov, compile PHP with --enable-gcov,​ and now you're ready. In summary: Install lcov, compile PHP with --enable-gcov,​ and now you're ready.
  
-How do I find what needs a test?+===== How do I find what needs a test? =====
   * Go to gcov.php.net   * Go to gcov.php.net
   * Choose a branch, then '​coverage'​   * Choose a branch, then '​coverage'​
   * Will go into some detail on what it means   * Will go into some detail on what it means
  
-How do I create a test?+===== How do I create a test? =====
   * Go to http://​qa.php.net/​...   * Go to http://​qa.php.net/​...
  
-Do you have a good example of a test and what it covers?+===== Do you have a good example of a test and what it covers? ​=====
   * Yes...   * Yes...
  
-How do I cover uncovered code?+===== How do I cover uncovered code? =====
   * Locate a file with a percentage < 100%   * Locate a file with a percentage < 100%
   * Use the legend to determine uncovered code   * Use the legend to determine uncovered code
   * Write code that will execute it   * Write code that will execute it
-  *  
  
-How do I determine if the desired code gets executed?+===== How do I determine if the desired code gets executed? ​=====
   * make lcov   * make lcov
   * view lcov_html/​index.html   * view lcov_html/​index.html
Line 48: Line 45:
     * Note: The TESTS var is to speed-up the process, as it will only run the specific test(s)     * Note: The TESTS var is to speed-up the process, as it will only run the specific test(s)
  
-How and where do I submit my test?+===== How and where do I submit my test? =====
 You can submit tests to the development mailing list @ internals@lists.php.net You can submit tests to the development mailing list @ internals@lists.php.net
  
-What is open-box and black-box testing and why do I care?+===== What is open-box and black-box testing and why do I care? =====
  
-Do I need valgrind? When and why might I use it?+===== Do I need valgrind? When and why might I use it? =====
 Short answer: You don't. Short answer: You don't.
 Long answer: valgrind can be used to detect if some test triggers a memory-related bug in PHP. Although running the test suite with valgrind is a plus, but it takes ages. You can submit tests without running valgrind, because the http://​gcov.php.net project will do that for you. Long answer: valgrind can be used to detect if some test triggers a memory-related bug in PHP. Although running the test suite with valgrind is a plus, but it takes ages. You can submit tests without running valgrind, because the http://​gcov.php.net project will do that for you.
  
-How do I install lcov on Linux, Mac, and/or Windows? What part of the package do I need? +===== How do I install lcov on Linux, Mac, and/or Windows? What part of the package do I need? ===== 
- +Just untar it and run make install.
-just untar it and run make install.+
doc/articles/writing-tests.txt · Last modified: 2017/09/22 13:28 (external edit)