[Notes] [Git][BuildStream/buildstream][aevri/unit_tests] contributing: add guidance on unit tests



Title: GitLab

Angelos Evripiotis pushed to branch aevri/unit_tests at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • CONTRIBUTING.rst
    ... ... @@ -1525,6 +1525,24 @@ Tests that run a sandbox should be decorated with::
    1525 1525
     
    
    1526 1526
     and use the integration cli helper.
    
    1527 1527
     
    
    1528
    +You should first aim to write tests that exercise your changes from the cli.
    
    1529
    +This is so that the testing is end-to-end, and the changes are guaranteed to
    
    1530
    +work for the end-user. The cli is considered stable, and so tests written in
    
    1531
    +terms of it are unlikely to require updating as the internals of the software
    
    1532
    +change over time.
    
    1533
    +
    
    1534
    +It may be impractical to sufficiently examine some changes this way. For
    
    1535
    +example, the number of cases to test and the running time of each test may be
    
    1536
    +too high. It may also be difficult to contrive circumstances to cover every
    
    1537
    +line of the change. If this is the case, next you can consider also writing
    
    1538
    +unit tests that work more directly on the changes.
    
    1539
    +
    
    1540
    +It is important to write unit tests in such a way that they do not break due to
    
    1541
    +changes unrelated to what they are meant to test. For example, if the test
    
    1542
    +relies on a lot of BuildStream internals, a large refactoring will likely
    
    1543
    +require the test to be rewritten. Pure functions that only rely on the Python
    
    1544
    +Standard Library are excellent candidates for unit testing.
    
    1545
    +
    
    1528 1546
     
    
    1529 1547
     Measuring performance
    
    1530 1548
     ---------------------
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]