Questions tagged as 'junit'

1
answer

How to run a suite of suites in JUnit?

I have the following suites below: @RunWith(Suite.class) // this other matters @Suite.SuiteClasses({ TestC.class, TestB.class, TestA.class }) public class MySuiteA {} @RunWith(Suite.class) // this other matters @Suite....
asked by 31.01.2014 / 21:04
1
answer

Write unit tests for interface or implementation?

Given the following test scenario, where I have the interface: public interface UserService { /** * Registra um usuário no sistema. * * @param user * Usuário à ser registrado. Não deve ser {@code null}...
asked by 24.04.2015 / 16:25
3
answers

Unit test with the database

I have an application that uses JPA 2 with Hibernate behind and for unit tests, I use HSQLDB in memory with JUnit 4.11. The HSQLDB is configured in a persistence.xml file in a META-INF folder. My question is: How do I upload the clean databas...
asked by 13.12.2013 / 01:06
2
answers

What is the advantage of using JUnit to test methods of a class?

I've created an application that basically is a class that tests whether the methods of another class are returning the expected values. My teacher asked me to rephrase this class as a JUnit test case. I did as he asked, but in the end I get the...
asked by 05.04.2016 / 15:12
2
answers

Mock of static method with Demoiselle and PowerMock / Mockito

I'm trying to mock a static method, but PowerMock requires the use of a specific Runner (PowerMockRunner) for mock static to work! And for Demoiselle to work you have to start Weld with DemoiselleRunner, but the JUnit API only accepts a singl...
asked by 11.02.2014 / 14:34
1
answer

How to simulate a user logged into an application with Demoiselle 2.4.2?

I have a Demoiselle 2.4.2 application already running that needs to use SecurityContext to get the User currently logged in and make some decisions. The time now is to write the unit tests using JUnit 4 for this application (th...
asked by 25.02.2016 / 16:13
2
answers

What kind of tests can I still do in this code?

I'm doing a test run in a simple bank application, but I do not know what kind of test I can do in that system to cover 100% of the code, it's only covering 61%. I already did all the tests with lower values, equal and higher, I did with anonymo...
asked by 25.11.2014 / 13:19
3
answers

Is it possible to test only specific classes?

I have two test classes: class A { @Test public void fazAlgo(){ // ... } } class B { @Test public void fazAlgoMesmo(){ // ... } } My tests are taking a long time because all classes are being tested. Ther...
asked by 09.12.2015 / 19:42
2
answers

JUnit 5 - How to run a test method only if another test method passes?

It would look something like this: @Test void metodo1() { assertTrue(...); } @Test void metodo2() { //Deve ser executado após método1(), e SOMENTE SE metodo1() passou! assertTrue(...); } I need to do this for cases where it does not ma...
asked by 24.02.2018 / 19:52
2
answers

What is the best way to define access to the methods of a class I want to use for unit testing?

I have a Runnable class, which does a lot of things on my system. When I created her, I did not want to instantiate her methods out of her scope. So I wrote the methods as protected . Now, I'm trying to write some unit tests for...
asked by 12.07.2018 / 15:25