This is a companion repository for Andrew Weeks and Javin Hung SpringOne Explore talk. You can find this plugin on gradle here.
- Include the plugin in your build.gradle Using the plugins DSL:
plugins {
id "io.enfuse.ChatGPTPlugin" version "X.Y.Z"
}
Using legacy plugin application:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.enfuse.plugin:chatgpt-test-gradle-plugin:X.Y.Z"
}
}
apply plugin: "io.enfuse.ChatGPTPlugin"
Update X.Y.Z with the your preferred versions. You can find available versions here.
- Create a properties file (e.g. env.properties) and include your openAIAPIKey. You can find a template here env.properties.template
#required
openAIKey=sk-XXXXXXXXX
# optional
openAIOrganization=
temperature=0
model=text-davinci-003
- Update configuration in your build.gradle file. You can change the path to your properties file.
chatGPT {
path = "env.properties" // optional, this is default
codeDirectory = "./src/main/java/" // optional, this is default
testDirectory = "./src/test/java" // optional, this is default
}
$ ./gradlew test
> Task :test
GreetingServiceTest > save_shouldSaveCandidate() FAILED
org.opentest4j.AssertionFailedError: expected: <this is amazing content> but was: <null>
Calling ChatGPT for test resolution:
The test code is expecting the response from the save() method to have a content value of "this is amazing content", however, the source code is not setting the content value of the GreetingRecord object. To fix this, the content value should be set in the source code before the GreetingRecord object is saved. This can be done by adding the following line of code to the save() method:
record.setContent(request.getContent());
16 tests completed, 1 failed
> Task :test FAILED
If you find something wrong or suggestion, please free feel to submit a PR and assign to @andyrewwer
or create an issue specifying branch and as many details as possible.