Created
January 22, 2023 20:49
-
-
Save Wassmd/f594cab7b0a2fef769b9c40bf337a539 to your computer and use it in GitHub Desktop.
Spock Test
This file contains hidden or 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 com.paxier.currencyexchange.controller | |
import spock.lang.Specification | |
class FirstTestSpec extends Specification { | |
def "one plus one should be two"() { | |
expect: | |
1 + 1 == 2 | |
} | |
def "two plus two should be equals to four"() { | |
given: | |
int left = 2 | |
int right = 2 | |
when: | |
int result = left + right | |
then: | |
result == 40 | |
} | |
def "Should be able to remove from List"() { | |
given: | |
def list = [1,2,3,4] | |
when: | |
list.remove(0) | |
then: | |
list == [2,3,4] | |
} | |
def "Should get index out of bound when removing non-existing items"() { | |
given: | |
def list = [1,2,3,4] | |
when: | |
list.remove(10) | |
then: | |
thrown(IndexOutOfBoundsException) | |
list.size() == 4 | |
} | |
def "numbers to the power of two"( | |
int a, | |
int b, | |
int c | |
) { | |
expect: | |
Math.pow(a, b) == c | |
where: | |
a | b | c | |
1 | 2 | 1 | |
2 | 2 | 4 | |
3 | 2 | 10 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment