Team,
I am trying to find the best way to test database access with spock with maven and spring.
I have DataAccess components (jdbc template ) and would like to make assertions on this component with spock.
I am new to this and I am looking for the best testing pattern to use.
I do not want to embed raw sql in the tests as this logic is already wrapped in my project.
In addition, it would be helpful to have a fully working maven web project with test configuration setup
I have also tried to follow this pattern here.
Test code I have tried, but I get compilation errors
[ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.5:testCompile (default) on project geb-maven-example: startup failed:
[ERROR] /D:/development/workspace/gebmaven/src/test/groovy/DataAccessSpec.groovy: 20: expecting '}', found ':' @ line 20, column 53.
[ERROR] ku MWFP and customerclass RFG":
@ContextConfiguration("classpath:applicationContext.xml")
class DataAccessSpec extends Specification {
// this is a JAVA data access component object from the web project
@Autowired
CopsPartsInfoBatchDAO copsPartsInfoBatchDAO
def "find if a part exists" () {
given "a part with sku MWFP and customerclass RFG":
// this is a JAVA object from the web project
def part = new CopsPartsInfo
String partNumber = "MWFP"
String customerClass = "RFG"
part.setSku(partNumber)
part.setExpandedsku(partNumber)
part.setPartnumber(partNumber)
part.setCustomerClass(customerClass)
when "checking if this part exists":
doesExist = copsPartsInfoBatchDAO.exists(part)
then: "this part must exist"
doesExist == true
}
}