Negative testing with Workflows

I have posted this question on StackOverflow as well (https://stackoverflow.com/questions/62158608/how-to-create-a-negative-test-case-in-github). I’m trying to figure out how to test a negative path with a workflow. I have created a simple test for a mathematical function in a shell script. The idea is to test if it computes f(x,y)=y-x. To do that there are three parameters, x, y, and the expected answer. I want to include tests for negative cases. In other words if the script does not perform as expected or experiences some error, that should cause a failure. What makes this difficult is that:
A) If the negative test fails it is doing what it should and it should be marked as a Pass.
B) If the negative test passes it is not doing what it should and it should be marked as a Fail.
C) I want all the tests in the set to execute regardless of the pass or fail rate.

I’m sure others have implemented this in their tests, but I’m not sure how that is worked into the framework of workflows and actions.

Hello @bsdillon, welcome to the community!

The requirements you list:

are almost exclusively satisfied by using some sort of test framework, such as jest for JavaScript code, rspec for Ruby code, bats for shell scripts, and many, many others. Then when you write your tests using the test framework, you can execute all the tests for your project with one simple command. That keeps a workflow simple, like this one I have for testing one of my projects:

Also, by using a test framework instead of encoding the tests directly into the GitHub Actions workflow, you can execute your tests locally as well (which is useful if you need to test something when your Internet connection is down).

I hope that helps! Let us know if you have more questions.