springtestdbunit / spring-test-dbunit

Integration between the Spring testing framework and DBUnit
http://springtestdbunit.github.com/spring-test-dbunit/
Apache License 2.0
475 stars 238 forks source link

Per class setup and teardown #70

Closed bruce264 closed 9 years ago

bruce264 commented 9 years ago

This is basically an enhancement idea to add per class setup and teardown capabilities to the framework.

philwebb commented 9 years ago

I missed it earlier, but it looks like this has already been requested in #40. Closing this one to keep the conversation in one place.

bruce264 commented 9 years ago

Hi Phil,

So to start modifying the framework I guess I can use your idea of modifying the @Databasesetup annotation so that it takes a paramter and does either per class or method setup.

Do you think this change will affect many classes/have a ripple effect on all the framework?

Kind regards,

Bruce.

On Tue, Feb 24, 2015 at 9:38 PM, Phil Webb notifications@github.com wrote:

Closed #70 https://github.com/springtestdbunit/spring-test-dbunit/issues/70.

— Reply to this email directly or view it on GitHub https://github.com/springtestdbunit/spring-test-dbunit/issues/70#event-241438293 .

philwebb commented 9 years ago

I think it should be fine as long as the default value is "per method"

bruce264 commented 9 years ago

Ok I'll do that, also I have another question I haven't used GitHub to collaborate in an open source project, I am using IntelliJ, I selected checkout from VCS and then GitHub, it asked me for my account, should I be able to push from an alternate branch to the repository itself or should I push somewhere else and request a merge?

Regarding the change I am thinking of adding a boolean isPerClass field that defaults to false to the @DatabaseSetup annotation and then adding afterTestClass and beforeTestClass methods to DbUnitRunner that only act when the isPerClass value is set to true and then I would have the beforeTestMethod and afterTestMethod to not act when the flag is true as well, do you think this is a good approach or there might be a more elegant one?

Thank you very much and kind regards,

Bruce

On Wed, Feb 25, 2015 at 5:15 PM, Phil Webb notifications@github.com wrote:

I think it should be fine as long as the default value is "per method"

— Reply to this email directly or view it on GitHub https://github.com/springtestdbunit/spring-test-dbunit/issues/70#issuecomment-76072532 .

bruce264 commented 9 years ago

Hi Phil,

I have an update, I have started to move things around and added

@Override
public void beforeTestClass(TestContext testContext) throws Exception {
    runner.beforeTestClass(new DbUnitTestContextAdapter(testContext));
}

However I noticed hat the textContext variable at this point has a null connection which causes the database setup to fail, I am trying to think of a workaround for this issue.

Thanks and kind regards,

Bruce

On Wed, Feb 25, 2015 at 9:07 PM, bruce.w H bruce264@gmail.com wrote:

Ok I'll do that, also I have another question I haven't used GitHub to collaborate in an open source project, I am using IntelliJ, I selected checkout from VCS and then GitHub, it asked me for my account, should I be able to push from an alternate branch to the repository itself or should I push somewhere else and request a merge?

Regarding the change I am thinking of adding a boolean isPerClass field that defaults to false to the @DatabaseSetup annotation and then adding afterTestClass and beforeTestClass methods to DbUnitRunner that only act when the isPerClass value is set to true and then I would have the beforeTestMethod and afterTestMethod to not act when the flag is true as well, do you think this is a good approach or there might be a more elegant one?

Thank you very much and kind regards,

Bruce

On Wed, Feb 25, 2015 at 5:15 PM, Phil Webb notifications@github.com wrote:

I think it should be fine as long as the default value is "per method"

— Reply to this email directly or view it on GitHub https://github.com/springtestdbunit/spring-test-dbunit/issues/70#issuecomment-76072532 .

bruce264 commented 9 years ago

Hello Phil,

Yet another update, I've managed to do it, it's working now, but I had to make some changes, I noticed the project is using Java 8 and even though I have jdk 8 installed some parts of the project wouldn't compile to me so I had to temporarily disable the @Repeatable annotations and switch the compile version to 7 locally, I also broke some unit tests that I'll have to fix. (I also noticed that there are 3 failing unit tests in master)

Once again, amazing job with the framework, the tests are a lot faster with the per class initial implementation I have added to them.

I would like to show you my progress neverthless as I think it can be improved upon by your observations, should I push it to my git hub account or how can I do this?

Kind regards,

Bruce

On Thu, Feb 26, 2015 at 1:50 PM, bruce.w H bruce264@gmail.com wrote:

Hi Phil,

I have an update, I have started to move things around and added

@Override
public void beforeTestClass(TestContext testContext) throws Exception {
    runner.beforeTestClass(new DbUnitTestContextAdapter(testContext));
}

However I noticed hat the textContext variable at this point has a null connection which causes the database setup to fail, I am trying to think of a workaround for this issue.

Thanks and kind regards,

Bruce

On Wed, Feb 25, 2015 at 9:07 PM, bruce.w H bruce264@gmail.com wrote:

Ok I'll do that, also I have another question I haven't used GitHub to collaborate in an open source project, I am using IntelliJ, I selected checkout from VCS and then GitHub, it asked me for my account, should I be able to push from an alternate branch to the repository itself or should I push somewhere else and request a merge?

Regarding the change I am thinking of adding a boolean isPerClass field that defaults to false to the @DatabaseSetup annotation and then adding afterTestClass and beforeTestClass methods to DbUnitRunner that only act when the isPerClass value is set to true and then I would have the beforeTestMethod and afterTestMethod to not act when the flag is true as well, do you think this is a good approach or there might be a more elegant one?

Thank you very much and kind regards,

Bruce

On Wed, Feb 25, 2015 at 5:15 PM, Phil Webb notifications@github.com wrote:

I think it should be fine as long as the default value is "per method"

— Reply to this email directly or view it on GitHub https://github.com/springtestdbunit/spring-test-dbunit/issues/70#issuecomment-76072532 .

bruce264 commented 9 years ago

Hello Phil,

I hope you are doing ok, I guess you have been very busy with other projects, I am really interested in pushing this feature collaboratively with you or someone in charge of Spring Test DbUnit, please let me know what the next steps are.

Best,

Bruce

On Thu, Feb 26, 2015 at 10:41 PM, bruce.w H bruce264@gmail.com wrote:

Hello Phil,

Yet another update, I've managed to do it, it's working now, but I had to make some changes, I noticed the project is using Java 8 and even though I have jdk 8 installed some parts of the project wouldn't compile to me so I had to temporarily disable the @Repeatable annotations and switch the compile version to 7 locally, I also broke some unit tests that I'll have to fix. (I also noticed that there are 3 failing unit tests in master)

Once again, amazing job with the framework, the tests are a lot faster with the per class initial implementation I have added to them.

I would like to show you my progress neverthless as I think it can be improved upon by your observations, should I push it to my git hub account or how can I do this?

Kind regards,

Bruce

On Thu, Feb 26, 2015 at 1:50 PM, bruce.w H bruce264@gmail.com wrote:

Hi Phil,

I have an update, I have started to move things around and added

@Override
public void beforeTestClass(TestContext testContext) throws Exception

{ runner.beforeTestClass(new DbUnitTestContextAdapter(testContext)); }

However I noticed hat the textContext variable at this point has a null connection which causes the database setup to fail, I am trying to think of a workaround for this issue.

Thanks and kind regards,

Bruce

On Wed, Feb 25, 2015 at 9:07 PM, bruce.w H bruce264@gmail.com wrote:

Ok I'll do that, also I have another question I haven't used GitHub to collaborate in an open source project, I am using IntelliJ, I selected checkout from VCS and then GitHub, it asked me for my account, should I be able to push from an alternate branch to the repository itself or should I push somewhere else and request a merge?

Regarding the change I am thinking of adding a boolean isPerClass field that defaults to false to the @DatabaseSetup annotation and then adding afterTestClass and beforeTestClass methods to DbUnitRunner that only act when the isPerClass value is set to true and then I would have the beforeTestMethod and afterTestMethod to not act when the flag is true as well, do you think this is a good approach or there might be a more elegant one?

Thank you very much and kind regards,

Bruce

On Wed, Feb 25, 2015 at 5:15 PM, Phil Webb notifications@github.com wrote:

I think it should be fine as long as the default value is "per method"

— Reply to this email directly or view it on GitHub https://github.com/springtestdbunit/spring-test-dbunit/issues/70#issuecomment-76072532 .

philwebb commented 9 years ago

Hi @bruce264. Are you able to push the code that you've written so far to GitHub? You need to fork the repository (the button at the top of the page) and then add your fork as a remote repository and push it.

If you use the git command line and you have a local copy checked out from this repository the steps will be something like:

$ git remote add bruce264 https://github.com/bruce264/spring-test-dbunit.git
$ git checkout -b perclass
$ git push bruce265 perclass

There are some good guides about forking a repo here.

Once you have some code pushed I can pull it locally and take a look.

philwebb commented 9 years ago

Also, we should use issue #40 to discuss the issue.