ReadyAPI 'semantic analysis' error. I have stored my script libraries in bin folder and I am calling the getBuildingInfo
method from the groovy test script of ReadyAPI. Most of the time this method works fine but once in a while I get this error. I want to find out what the exact issue and fix the root cause.
I tested the code in eclipse and it works perfectly fine.
ERROR:BUG! exception in phase 'semantic analysis' in source unit 'Script15.groovy' The lookup for PropertiesQuery caused a failed compilaton. There should not have been any compilation from this call. BUG! exception in phase 'semantic analysis' in source unit 'Script15.groovy' The lookup for PropertiesQuery caused a failed compilaton. There should not have been any compilation from this call.
14: Apparent variable 'Database' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes: You attempted to reference a variable in the binding or an instance variable from a static context. You misspelled a classname or statically imported field. Please check the spelling. You attempted to use a method 'Database' but left out brackets in a place not allowed by the grammar. @ line 14, column 17. def dbConn = Database.getDbConnection(env);
public class Database {
public static Connection getDbConnection (String env){
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver")
switch (env){
case "TEST":
conn = DriverManager.getConnection("a","b","c")
break;
case "DEV":
conn = DriverManager.getConnection("a","b","d")
break;
}
return conn;
}
public static void closeDbConnection(Connection conn) {
conn.close();
}
}
class PropertiesQuery {
public static String getBuildingInfo(String env, String id, int row ){
String result = "111";
def query = "SELECT col1, col2 FROM tabl1 WHERE id = 1"
def dbConn = Database.getDbConnection(env);
def stmt = dbConn.createStatement()
def rs = stmt.executeQuery(query);
while(rs.absolute(row)){
rs.getString("col1")
rs.getString("col2")
result = rs.getString("col1") +"/"+rs.getString("col2")
return result;
}
}
}