Diff for /wikisrc/tutorials/atf.mdwn between versions 1.8 and 1.9

version 1.8, 2010/09/03 16:27:02 version 1.9, 2010/09/03 16:32:26
Line 69  require comments to explain what they in Line 69  require comments to explain what they in
   
 # Test case parts  # Test case parts
   
 A test case is composed by three parts: the *head*, the *body* and the  
 *cleanup*.  Only the body is required; the other two routines are optional, but  
 you are strongly encouraged to provide the *head*, if only to describe the  
 purpose of your tests by setting the *descr* property.  
   
 ## The head  ## The head
   
 The *head* is used **for the sole purpose** to define meta-data properties for  The *head* is used **for the sole purpose** to define meta-data properties for
Line 104  every test case to prevent side-effects  Line 99  every test case to prevent side-effects 
 in-memory data corruption, etc.).  In particular:  in-memory data corruption, etc.).  In particular:
   
 * A test case is **always executed as a subprocess** that is separate from the  * A test case is **always executed as a subprocess** that is separate from the
   head and the cleanup.  This implies that you cannot pass any in-memory state    head.  This implies that you cannot pass any in-memory state between the
   between the three parts.  The only exception is that the body and the cleanup    parts.
   share the same temporary directory, so you can use the file system to pass  
   information between them.  
   
 * The current working directory of a test case is changed to a temporary  * The current working directory of a test case is changed to a temporary
   location that gets cleaned up later on automatically.  (Set the use.fs    location that gets cleaned up later on automatically.  (Set the use.fs
Line 282  specific details as to how this works fo Line 275  specific details as to how this works fo
             atf_tc_fail("Condition not met!"); /* Abort execution. */              atf_tc_fail("Condition not met!"); /* Abort execution. */
     }      }
   
     ATF_TC_WITHOUT_HEAD(tc, another_test_case);      ATF_TC(tc, another_test_case);
       ATF_TC_HEAD(tc, another_test_case)
       {
           atf_tc_set_md_var(tc, "descr", "This test case ensures that...");
       }
     ATF_TC_BODY(tc, another_test_case)      ATF_TC_BODY(tc, another_test_case)
     {      {
         /* Do more tests here... */          /* Do more tests here... */
Line 400  The details on how this works are provid Line 397  The details on how this works are provid
     }      }
   
     atf_test_case another_test_case      atf_test_case another_test_case
       another_test_case_head() {
           atf_set "descr" "This test case ensures that..."
       }
     another_test_case_body() {      another_test_case_body() {
         # Do more tests...          # Do more tests...
     }      }
Line 581  do: Line 581  do:
     #include <signal.h>      #include <signal.h>
     #include <stdio.h>      #include <stdio.h>
   
     ATF_TC_WITHOUT_HEAD(tc, integer_formatter);      ATF_TC(tc, integer_formatter);
       ATF_TC_HEAD(tc, integer_formatter)
       {
           atf_tc_set_md_var(tc, "descr", "Tests the %d formatter for snprintf");
       }
     ATF_TC_BODY(tc, integer_formatter)      ATF_TC_BODY(tc, integer_formatter)
     {      {
         char buf[1024];          char buf[1024];
Line 595  do: Line 599  do:
         ATF_CHECK_STREQ("Hello 5", buf);          ATF_CHECK_STREQ("Hello 5", buf);
     }      }
   
     ATF_TC_WITHOUT_HEAD(tc, string_formatter);      ATF_TC(tc, string_formatter);
       ATF_TC_HEAD(tc, string_formatter)
       {
           atf_tc_set_md_var(tc, "descr", "Tests the %s formatter for snprintf");
       }
     ATF_TC_BODY(tc, string_formatter)      ATF_TC_BODY(tc, string_formatter)
     {      {
         char buf[1024];          char buf[1024];

Removed from v.1.8  
changed lines
  Added in v.1.9


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb