-->

Connect dbslim with Fitnesse

2019-08-09 00:27发布

问题:

I'm trying to connect to a database from Fitnesse, but it keeps giving an error message. I'm using dbslim of MarkFink: https://github.com/markfink/dbslim

the message I keep getting is: Could not invoke constructor for DbSlimSetup

this is my current page:

!contents -R2 -g -p -f -h

!define TEST_SYSTEM {slim} 

!*> setup
|import|
|fitnesse.slim.test|
|fitnesse.fixtures|
|slim|

| script | Db Slim Setup |!-oracle.jdbc.driver.OracleDriver-!| jdbc:oracle:thin:@host_name:1521:database_name | username | password |

回答1:

Most likely you did not include the dbslim jar / or the path to the generated .class files into your classpath when invoking test. Try putting in something like below on the test page (or actually anywhere on the path of your test case)

!path /the/path/to/your/project/output

The path is the place that your generated .class files will go if you directly include source code of Db Slim; if you built it as a jar, use the path to the jar.

To explain this a little bit, FitNesse will invoke the actual test system in the runtime, or in another word, the test cases are running on a seperate process than the FitNesse webserver itself. By default, FitNesse will only include fitnesse.jar in the classpath of the invoked process. When you call !path, you actually include the path to the accumulated classpath of the invoked process. You can find out more on !path here