I must stop the application when I run a test

Asked

Viewed 53 times

0

I currently have my application in production and need to create some tests (Junit). My question is whether I need to stop the application or can run the direct test.

Has anyone passed or knows anything about it?

  • 3

    I believe you still do not understand the concept of Tests. I recommend reading the article: https://www.devmedia.com.br/junit-tutorial/

2 answers

4


Your question doesn’t even make sense. Running Junit tests has nothing to do with running in production.

Junit tests are sort of an extension of the build process. You compile your project and run the tests. If the tests get anything wrong, the build process is cut with an error status (although you can choose selectively to let it go even if some specific tests fail). Note that this process is carried out on the developer’s machine.

In a mature development process, when the tests pass, you take the JAR/WAR/EAR/etc produced and put it into production. But nothing prevents you from doing the same with a JAR/WAR/EAR/etc that has not been tested with Junit (not a good idea, but you can if you want).

Running Junit tests in production is something that doesn’t exist and doesn’t make any sense since Junit runs the tests on the developer’s machine, not in production.

As for stopping an application in production because of testing on Junit, this makes even less sense, since the two things are running on different machines. And even if it is on the same machine, that would be the same as wanting to stop the application in production to run the compiler (ie, nonsense).

  • It turns out, the application is already running in production and I’m doing some maintenance, so I created some tests to then upload the changes. Then I was in doubt about it, whether it would be necessary for the application or not. But your answer gave a light, It was really worth!

1

You should do the tests Before to send the code to production.

Ideally, there is an approval environment for testing, and if testing passes, then only then do you send the codes to the production environment. It is important to keep in mind that the more atomic your classes and methods are, the more uncoupled your code will be and the less likely it is that some problem will occur during testing, since a modification does not usually result in a cascade of reactions.

There’s no such thing as testing a code that’s already in production. If there is no type-approval environment, the tests may be carried out on the machine used for the development before the code is sent, bearing in mind that the test environment may be different from the production one. If you are not applying the continuous integration process, I highly suggest you read about it for use in your work cycle.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.