spring-test-dbunit | Integration between the Spring testing framework | Functional Testing library
kandi X-RAY | spring-test-dbunit Summary
kandi X-RAY | spring-test-dbunit Summary
The project can be configured to run DBUnit tests using a Spring TestExecutionListener.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of spring-test-dbunit
spring-test-dbunit Key Features
spring-test-dbunit Examples and Code Snippets
Community Discussions
Trending Discussions on spring-test-dbunit
QUESTION
We run our tests with spring-db-unit, the forked and maintained one. The tests run just fine and can access and modify the data. But when I was debugging some tests I realized that the database stays empty all the time! My assumption is that the runner creates a transaction and rolls it back at the end of the test instead of commiting.
How can I inspect the data or persist it in the database at the end (or anytime, really!) of a test?
The setup:
Our config is follows the suggested setup from the gibthub readme:
...ANSWER
Answered 2020-Jul-27 at 08:50Rolling back transactions isn't spring-test-dbunit fault. It works with and without transactions. The roll back is the default behavior of the TransactionalTestExecutionListener
.
Citing the javadoc of the class:
By default, test transactions will be automatically rolled back after completion of the test; however, transactional commit and rollback behavior can be configured declaratively via the
@Rollback
annotation at the class level and at the method level.
The solution is to put @org.springframework.test.annotation.Rollback(false)
on the test class or method.
QUESTION
I am currently migrating an application from maven to gradle (4.10.2). In maven, a tar.gz-file would be generated with configuration, dependencies and some empty directories that would then be used by the application during runtime.
In gradle i am using the distribution plugin to create the tar.gz using the distTar-Task.
To create the empty directories inside the tar.gz, i create them in the build-directory and then have them copied by distTar into the tar.gz.
I managed to finally get this by creating a task createEmptyDirectories
that would just create the directories and be done with it.
distTar would dependOn this task so that the directories are created before the tar.gz or so i thought.
The task createEmptyDirectories
however is always skipped during build (using gradle clean build
):
ANSWER
Answered 2018-Oct-31 at 14:01First thing: you should wrap custom stuff that you want your task to do in a doLast { ... }
closure.
QUESTION
Test class declaration
...ANSWER
Answered 2018-May-14 at 18:49It says right there in your stack trace:
QUESTION
I'm trying to use dbunit to test my DAOs. We use Spring in a version that is not compatible with spring-test-dbunit. I can't autowire my dao beans into my test class, because then I would have to use @RunWith(SpringJUnit4ClassRunner.class)
which regards one parameterless constructor. My class looks like following:
ANSWER
Answered 2018-Mar-04 at 04:02Since you are using Spring, I suggest autowiring the dbUnit instances into the test. The dbUnit Test Cases page has "Configuration Example Using Spring" for the PrepAndExpectedTestCase
, but just copy the code and change it to DBTestCase
and adjust accordingly.
QUESTION
I've set up spring-test-dbunit but I get following exception:
testSometing(com.my.package.dbunit.DbUnit) Time elapsed: 13.013 s <<< ERROR! java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.findAnnotation(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
The test class looks like following:
...ANSWER
Answered 2018-Feb-27 at 12:56Your version of spring-test-dbunit
is most probably incompatible with your spring-version. spring-test-dbunit
in version 1.3.0 (which seems to be the most recent one) depends on Spring 4.2.5. You are probably using a more recent Spring version in your project which does not have a findAnnotation
method in AnnotationUtils
any more.
You basically have two things that you can do right now:
- Use Spring 4 (which might be problematic in the future, when support is dropped)
- Find an alternative to
spring-test-dbunit
QUESTION
I am using the latest SonarQube 6.4, Jenkins 2.60.1 and I have one application with some tests. After running the application in eclipse using the coverage plugin I can see approximately 90% in test coverage. My problem starts when I use Jenkins to build my application and then SonarQube displays the result but the test coverage is always null. I believe that I am missing something so any help will be appreciated.
Here is my pom.xml file:
...ANSWER
Answered 2017-Jul-17 at 13:48The post build action is deprecated.
Yours is a Maven project, so there's no need to provide properties explicitly.
As described in the docs, after your build command all you really need to do is this: $SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL
QUESTION
When extending the spring CrudRepository class - it's enforcing me to override the save method from the interface. I am unable to call it without receiving the following error:
I was of the opinion this was a default method that was built into the interface. I am able to call repository.findAll() successfully without having to modify anything. Can you help explain this?
My repo:
...ANSWER
Answered 2017-Jul-10 at 12:29you are extending CrudRepository
but are trying to save List
hence the error not finding the save(List)
QUESTION
It seems this situation appears before, and was asked& answered, but situation is changed because of updated versions...
I tried my Spring DBUnit test with default configuration (connecting to h2db
, i've checked, h2db is used correctly):
ANSWER
Answered 2017-May-03 at 13:10It seems I used too old version of spring-test-dbunit
(I've used old article). I've replaced it with:
QUESTION
...ANSWER
Answered 2017-Feb-28 at 03:41According to this forum https://sourceforge.net/p/dbunit/mailman/message/20643023/ it doesn’t seem like DBUnit has a way to “quote” the table name. But you can configure DatabaseDataSourceConnectionFactoryBean
if you do not want to rename tables for some reason or working with legacy database
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-test-dbunit
The @DatabaseSetup annotation indicates how database tables should be setup before test methods are run. The annotation can be applied to individual test methods or to a whole class. When applied at the class level the setup occurs before each method in the test. The annotation value references a file that contains the table DataSet used when resetting the database. Typically this is a standard DBUnit XML file, although it is possible to load custom formats (see below). Here is a typical setup annotation. In this case a file named sampleData.xml is contained in the same package as the test class.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page