Question for my fellow programmers. I need to test that a SQL statement will truncate a table without actually truncating the table. I do know that I need to disable the constraints before truncating it, but I'm at a lost of how to actually truncate the table without actually causing "permanent damage" to the table.
Sorry if it's already been asked, and thanks in advance!
Edit: I forgot to mention, I'm using Maven, MyBatis, Oracle DB, and Spring (Aspect, Batch). Also, the code works, but within the context of a JUnit, the method needs to be tested. Though how I will assert it is yet another problem I will soon need to deal with.
Consider using inmemory database engine for unit tests, such as Derby. This should allow you to truncate table without damaging real data. A good approach is to use different drivers for production and test purposes. This approach is especially convenient if you are using some ORM framework like Hibernate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With