Hi Rafael, Many thanks for your interest and contributions.
@DatabaseTest controls transactions (i.e. rollback/commit), and enables them at the test level. Tests have to be part of a transaction to follow a pattern such as: load data; run test; verify db data; rollback transaction. Without rollback, this is not really necessary as db status can be checked after commit (i.e. outside the transaction). If you look at the implementation, @DatabaseTest (and @DatabaseNoRollbackTest) is just an extension of the Deltaspike @Transactional interceptor (see TestAwareTransactionStrategy). @DatabaseTest is kept separate from @DatabaseSetup for clarity. They could be joined I guess, but I am not sure I'd like it. If you want to run your tests using an IDE you'll need to start the derby server manually or alternatively you could use derby embedded (that can be configured in persistence.xml). I prefer to use maven and derby (or hypersonic) in server mode. Cheers, Luigi On Wednesday, February 17, 2016 2:45 AM, Rafael Pestano <[email protected]> wrote: Hi again, Just sent a PR <https://github.com/lbitonti/deltaspike-dbunit/pull/1> for yaml and json datasets. One thing that Im not happy (probably because I always use yml) is that have to add an extra annotation to say what kind of dataset we are working on, so my test looks lke this: @RunWith(CdiTestRunner.class) @DbUnitConfiguration(dataSetLoader = YamlDataSetLoader.class) @DatabaseTest @DatabaseSetup(value = "../setup-db.yml", type = DatabaseOperation.CLEAN_INSERT) @DatabaseTest to enable transactions, I really don't use this on my tests cause transactions in my app are handle by CDI (but I see I would need this if transactions were managed by ejbs or spring for example). Also if possible would try to reuse @Transactional from deltaspike here. @DbunitConfiguration: here I think we could infer dataset loader from dataset name sulfix or use a global configuration class/ file because you usually will use one type of dataset in a project. @DatabaseSetup is to only annotation I want in 90% of my dbunit tests. WDYT? About the tests, can you run them through the IDE? when I run in the IDE derby is not started, with maven everything is ok. 2016-02-16 18:57 GMT-02:00 Rafael Pestano <[email protected]>: > Hi Luigi, > > great job, I'm a big fan of dbunit. > > I have some questions: > > why do you need @DatabaseTest annotation, only @DatabaseSetup wouldn't be > sufficient? > > do you plan to support other dataset types like yml or json? > > There is a way to execute scripts before and after the test? > > I see that we can attach replacers however a common use case is to use > relative dates in datasets, there is plan for a built in datetime replacer? > > I already have implemented some of the items above and can contribute if > you have interest. > > thank you for porting it to deltaspike! > > > 2016-02-16 15:18 GMT-02:00 Gerhard Petracek <[email protected]>: > >> hi luigi, >> >> it's great that you share it with the community! >> we can link it in our documentation! >> >> regards, >> gerhard >> >> >> >> 2016-02-16 11:40 GMT+01:00 Luigi Bitonti <[email protected]>: >> >> > Hi All, >> > >> > I've released recently a library that allows integration between >> > Deltaspike TestControl and DBUnit. It allows, using simple annotations, >> to >> > setup and teardown database tables as well as checking expected table >> > contents once a test completes. >> > >> > Basically something like: >> > >> > >> > @DatabaseTest@DatabaseSetup("../setup-db.xml") >> > .... >> > @ExpectedDatabase(value = "extra_and_default_category-expected.xml", >> > assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED) >> > >> > >> > More information is available at: >> > >> > http://lbitonti.github.io/deltaspike-dbunit/ >> > https://github.com/lbitonti/deltaspike-dbunit >> > >> > >> > It's essentially a port of springtest-dbunit, for those familiar with >> it, >> > to cdi/deltaspike. >> > Hopefully it will be useful to other people as well. Feedback welcome. >> > >> > Cheers, >> > Luigi >> > >> > > > > -- > <http://www.advancedit.com.br/>Att, > > Rafael M. Pestano > > Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul > http://rpestano.wordpress.com/ > @realpestano <https://twitter.com/realpestano> > -- <http://www.advancedit.com.br/>Att, Rafael M. Pestano Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul http://rpestano.wordpress.com/ @realpestano <https://twitter.com/realpestano>
