Well first off, this is really an integration test... So I would switch to
have failsafe run the tests: ie add failsafe:integration-test and
failsafe:verify to your project's lifecycle (perhaps even in a profile)
Then I would use
http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html#additionalClasspathElementsin
multiple executions of the failsafe:integration-test config to add the
different directories for each environment that you want to test against
So you would have:
* an execution of failsafe:verify bound to the verify phase to check all
the aggregate results
* an execution of failsafe:integration-test bound to the integration-test
phase with additionalClasspathElements pointing to
src/test/oracle-resources which has a test-context.xml pointing to the
oracle DB
* an execution of failsafe:integration-test bound to the integration-test
phase with additionalClasspathElements pointing to src/test/db2-resources
which has a test-context.xml pointing to the DB2 DB.
Etc
It's not completely ideal in that you are hard-coding the DB connection
detail in source control... If I were doing it I would seek to either only
enable the DB-specific integration tests based on the existence of the
corresponding test-context.xml (profile activation) source control would
have a test-config.xml.template and ignore the test-config.xml so that I
can have my own local test env that is separate from yours and we are not
fighting over who's test-config.xml to merge... Or I would use resource
filtering to inject the config by properties (activating the profile based
on the presence of the property). The second route would probably be more
verbose so I would probably write a helper plugin... Haven't needed to do
that yet, hence I haven't written such a plugin ;-)
HTH
- Stephen
On Friday, 23 May 2014, Gordon Cody gordon.c...@zafin.com wrote:
We have to begin running junit tests using more than 1 database type. I am
wondering how best to run all unit tests using oracle then run all of the
tests again using db2 then postgres. I figured some of you out there must
have a similar requirement.
Currently we have test/resources/test-context.xml that contains
bean id=dataSource
class=org.apache.commons.dbcp.BasicDataSource
destroy-method=close lazy-init=true
property name=driverClassName
value=com.p6spy.engine.spy.P6SpyDriver /
property name=url value=jdbc:oracle:thin:@localhost:1521:
/
property name=username value=x /
property name=password value=x /
property name=accessToUnderlyingConnectionAllowed value=true
/
property name=defaultAutoCommit value=false /
property name=maxWait value=0 /
property name=maxActive value=-1 /
/bean
There is nothing in the pom.xml explicitly related to unit tests other than
dependency
groupIdjunit/groupId
artifactIdjunit/artifactId
version4.8.2/version
/dependency
Quick sanity builds are done by our CI system using
mvn package -e -Dmaen.test.skip=true
Due to how long the tests take to complete they are only run daily using
mvn test -e -Dtest=com.zafinlabs.someapp.somemodule.TestSomeProcess
Suggestions please.
--
Best Regards, Gord Cody
Release Manager Zafin Labs Americas Inc.
179 Colonnade Road-Suite 100, Ottawa ON, Canada
Phone: +1 (613) 216-2504 Fax: +1 (613) 688-1374 Mobile: +1 613-601-2734
Web: http://zafin.com Email: gordon.c...@zafin.com javascript:;
--
Zafin - Canada
--
http://zafin.com
http://zafin.com/
--
Connect with us
http://www.youtube.com/user/ZafinGlobal
http://www.linkedin.com/company/Zafin
http://twitter.com/Zafin
News and Events
Zafin among Top 10 FinTech Companies to Watch in 2014: American Banker
http://zafin.com/zafin-among-top-10-fintech-companies-to-watch-in-2014-american-banker/
--
Sent from my phone