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.
You can see the working function:
You can see the tests outlined in the test file:
- Function adds together positive integers within input list
- Input is only a list
- Input list only contains positive integers
- Input list is not empty
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)