How does Junit work?

Asked

Viewed 294 times

2

How does the Junit open-source framework work? Does it guarantee the quality of the software? It is recommended to write unit tests on a daily basis?

  • 3

    I changed the final question so that it doesn’t seem that the question is opinionated and is closed. If you think it can be improved, you can edit without problems :)

  • All right, thank you!

2 answers

5


how the Junit framework works

At work, we use Junit to ensure the outcome of our system. At any time, we send the IDE to perform the automatic tests to see if there is anything out of the expected.

it ensures increase in quality?

Not on its own. It can be used for TDD (development directed to tests) and also as a guarantee to detect software regression (regression: something worked before but no longer works).

The assurance of the tests depends much more on the test designer than only Junit himself. If the test is poorly programmed, Junit will not perform miracles. Possibly its existence is worse for development than if the tests did not exist.

day to day, you recommend the writing of unit tests?

SIIIIM!!!!! With all the strength! Develop using TDD method and you will have much less headache. Not to mention that you can test the pure logic of your program without UI.

This UI-free testing tip is especially important for tests where the interaction with the UI is long enough to reach the desired stretch or if climbing the UI is traumatic. (Example of raising traumatic UI: poorly structured GWT projects, it may take more than 40 minutes to climb the server, only then start testing).

1

How the Junit open-source framework works?

The Junit framework serves to verify that what is being produced works properly. Usually most bugs are not by syntax error, but by problems in the output validations ( Who never puts an extra 'Else' in the 'if-Else'? ). Then the framework will check the correct output. In it you will assemble the scenario and check its output (normally assertEquals is used).

It ensures increased software quality?

It by itself does not guarantee the quality increase, but if you use some simple techniques such as partition equivalence and check the limit values (a>0 && a<10), among others, you will find bugs more easily. Apart from the regression tests(redo the same test to see if nothing broke).

It is recommended to write unit tests on a daily basis?

It is so recommended that there are even methods like TDD and BDD, that the basis is this: You make unit test code every day, before your code.

There is an excerpt from Mauricio Anchine’s book (Software Testing) that asks the following question: "If I write unit tests before my code I will be productive?"

The author answers this way: If being more productive means more code, no. But if you talk about code quality and rework, you will be much more productive.

I hope I’ve helped

References:

https://www.devmedia.com.br/junit-tutorial/1432

https://www.casadocodigo.com.br/products/livro-testes-de-software

https://blog.locaweb.com.br/desenvolvedores/entenda-o-que-e-tdd-e-quais-sao-as-suas-vantagens/

Browser other questions tagged

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