/software-engineering-test-sample

Sample of test code for sum of positive integers.

Primary LanguagePython

pytests

Unit Test Example

Using any programming language that you know, write a function/method that accepts a list of positive integers as a parameter and returns the sum of the numbers in that list. Using an appropriate test framework, write automated tests to test that function. Make sure that your program returns an error if the list is empty or if some members of the list are not positive integers.

Function

You can see the working function:

utils.py

Tests

You can see the tests outlined in the test file:

test_utils.py

  • Function adds together positive integers within input list
  • Input is only a list
  • Input list only contains positive integers
  • Input list is not empty

Pipeline

The tests automatically run in the pipeline.

https://github.com/amajor/software-engineering-test-sample/actions/workflows/main.yml

  • Test for successful summation of any number of list items
  • Test input is only list of integers (throws exception if not)
  • Test input is only list of positive integers (throws exception if not)
  • Test for empty lists (throws exception if empty)

Passing Tests