Writing test cases to check for failed and successful builds
Creating a Project Repository
Now that we have everything set up, we can start making projects. Start by logging into your normal user (if you haven't already), then go to Projects -> New Project. You can remove the README.
Once it's been created, git clone your project into a directory
Making a simple calculator
To test if our runner works, we will create a simple program which we can upload then run tests and configure pipelines for.
Let's make a simple calculator. I'll be using Go for this example
calculator.go
package main
import "fmt"
func Add(x, y int) (res int) {
return x + y
}
func Subtract(x, y int) (res int) {
return x - y
}
func main() {
fmt.Println("Addition: ", Add(1, 2))
fmt.Println("Subtraction: ", Subtract(4, 2))
}
Test this by running go run calculator.go
Addition: 3
Subtraction: 2
Now that it works, we can push our demo app to our repository
> git switch -c main
> git add .
> git commit -m "Calculator Demo"
> git push origin main
Writing Test Cases
Now that we have a functioning program, we can write a test case to check whether the values are acceptable, if not it will fail the build. We will reuse the code above for this