org.spockframework:spock-core:0.7-groovy-2.0
Gradle 1.12
Groovy 1.8.6
java
Hello,
I am trying to use spock
with my java application to run unit tests and building with gradle
.
However, since I am new to spock, I am not sure how I can pass in the actual parameters to get a correct output?
This is the function signature I want to test, which takes in an inputStream, char[], and a String:
public String makeRequest(InputStream keystoreFilename, char[] keystorePassword, String cnn_url) {
...
}
So in my test specification, I want to pass the keystore file as an inputStream where the actual keystore is located here ../resources/keystore.bks, and the actual password for the keystore and the url to where the web service is. However, I get this error when trying to run the unit test:
groovy.lang.MissingMethodException: No signature of method: com.sunsystem.HttpSnapClient.SnapClientTest.FileInputStream()
My specification test is below, but I think I am going about this the wrong way.
import spock.lang.Specification;
import java.io.InputStream;
import java.io.FileInputStream;
class SnapClientTest extends Specification {
def 'Connect to https web service'() {
setup:
def snapzClient = new SnapzClient();
def inputStream = FileInputStream("../resources/keystore.bks")
def keystorePwd = "password".toCharArray()
def url = "https://example_webservice.com"
expect: 'success when all correct parameters are used'
snapzClient.makeRequest(A, B, C) == RESULT
where:
A | B | C | RESULT
inputStream | keystorePwd | url | 0
}
}
Many thanks for any suggestions,