Last active
August 10, 2017 08:38
-
-
Save utkarshmani1997/a29213abeb919e49c3ba49b29d2ee4c2 to your computer and use it in GitHub Desktop.
Demo of unit testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main_test | |
import ( | |
. "github.com/testing-demo" | |
. "github.com/onsi/ginkgo" | |
. "github.com/onsi/gomega" | |
) | |
var _ = Describe("Sum", func() { | |
var ( | |
p, q, m, n, sum1, sum2 int | |
) | |
BeforeEach(func() { | |
p, q, sum1 = 5, 6, 11 | |
// Putting wrong value of sum2 intentionally | |
m, n, sum2 = 8, 7, 16 | |
}) | |
Context("Addition of two digits", func() { | |
It("should return sum of the two digits", func() { | |
addition_of_two_digits := Sum(p, q) | |
Expect(addition_of_two_digits).Should(Equal(sum1)) | |
}) | |
It("should not return the sum provided", func(){ | |
addition_of_two_digits := Sum(m, n) | |
Expect(addition_of_two_digits).ShouldNot(Equal(sum2)) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment