Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JUnit Test Cases on Production

We have recently started TDD and we are writing JUnit test-cases for each of the RESTful webservices that we develop. Is it a good idea to run the JUnit test-cases on the production environment when a new version is released?

Background: Our web-app is enterprise web-app and has complex business logic. The plan is to use @After and @AfterClass to cleanup the test-data generated by running test-cases.

The web-app is available as both SaaS and on-premise editions and we are planning to validate upgrades for both edition if it's feasible and a good practice. I understand that we will be having this test-cases run on staging environment but to make sure that we have not broken anything during upgrade/deployment or environment has not created any diverse affect.

Now question is, "Is it good practice? if no what is suggested?"

like image 779
deej Avatar asked Oct 25 '25 02:10

deej


1 Answers

Your unit tests should just test the code. They shouldnt be modifying with external sources like databases and/or web services then they become integration tests.

Generally I would suggest running unit tests before building/deploying your project to production, these can be run on a build server or QA / staging server. Only if they all pass do you deploy to production, then you know the build is stable in that sense.

If you have integration tests that do speak to other services and may modify data etc, I wouldnt run these on production. I would run them on your QA/Staging server against the code that is about to be released to production.

like image 135
cowls Avatar answered Oct 26 '25 17:10

cowls



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!