Most voted "junit" questions
Popular unit testing framework for Java and Scala. The latest version, Junit 5, supports the new Java 8 added Features, for example lambda Expressions. Consider using in conjunction with the Java or Scala tag to indicate your use case.
Learn more…116 questions
Sort by count of
-
1
votes1
answer257
viewsHow to support transactions with Junit and Demoiselle 2.4.2
I have an application whose unit tests are fully operational except for write operations in the database. No data is recorded. When forcing a flush, I received the message indicating that no…
-
1
votes1
answer30
viewsPlugin to create runtime variable instance builder
I need to create some tests using variables already instantiated at runtime, and instead of manually mounting, object by object, attribute by attribute, I would like some tool that automates this…
-
1
votes1
answer172
viewsHow do I inject Ejbs that call other Ejbs into a Junit test class?
I’m trying to test a class in Junit. Turns out the class I’m testing has several Ejbs that call other Ejbs. How do I inject into a Junit EJB’s test class called other EJB’s? Thank you.…
-
1
votes0
answers569
viewsSelenium/Junit - Authentication screen not saved/executed
I’m doing a POC for using Selenium + Junit 4 for functional interface testing in a web tool. The tool in question requires authentication when opening the URL, and the test was saved to the Selenium…
-
1
votes1
answer662
viewsSpring boot test - Junit
How do I resolve this problem and run the Junit test on Spring boot? @RunWith(SpringRunner.class) @SpringBootTest @ActiveProfiles("test") @ContextConfiguration(classes = { CategoriaTest.class,…
-
1
votes1
answer340
viewsProblem with @Autowire Spring + Hibernate and Junit
Good evening, I’m trying to create a project using Hibernate and Spring, I was successful creating some configurations, including I was able to generate the database by booting the application using…
-
1
votes3
answers1748
viewsTest a constructor with more than one parameter
I am trying to create a test class for my constructor, but it receives three parameters and these parameters are validated within the class itself, to allow or not the creation of its instance.…
-
1
votes1
answer768
viewsTest main class input method with Systemin drive in test class
As I test the System.out.println() a method? The method I want to test displays the phrase: Enter the name > How do I test whether or not this phrase has been changed in the Test? main class:…
-
1
votes0
answers577
viewsSelenium opening two browsers even I instantiating only one
Galley, I am using Cucumber with Selenium in JAVA. I have the following problem: every step I do: private WebDriver driver; @Before public void before(){ driver = new FirefoxDriver(); }…
-
1
votes1
answer180
viewsSelenium perform task to the end
In tests with Selenium, running by Eclipse, when I run several at the same time. Errors happen: First, does not finish running the task opens another browser. Starts running the second test without…
-
1
votes0
answers66
viewsDriver does not wait for page to load to proceed
Hi, I’m using Selenium to run some tests and then export the code to the eclipse. I’m trying to gettext a page that uses ajax using xpath, and then I’m trying to authenticate with assertTrue, but…
-
1
votes1
answer587
viewsMock non-static method of a class containing a call from another static method
Hello, The title got a little fuzzy, but come on. I have the class below: public class ClasseA { public static final int constA = ClasseB.metodoB(); public int metodoA(){ System.out.println("Passei…
-
1
votes1
answer240
viewsSelenium does not find element
Follow the code. Selenium does not find the element: package test; import java.util.concurrent.TimeUnit; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import…
-
1
votes1
answer189
viewsfunction equals of object is not called during unit test
I’m developing unit test of a class with Junit and Mockite, and to facilitate the creation of a spy of this class I created a function that builds and returns this spy. The problem that is occurring…
-
1
votes0
answers106
views -
1
votes0
answers666
viewsHow to test one method that depends on the result of another with Junit?
Greetings, I have a class that does actions in an email. I created some tests for this class and would like to know if this is a valid form of testing or if there is any better way to do it. I test…
-
1
votes1
answer334
viewsHow to create a unit test using mockite in a list of objects
I know exactly what I need to mock about the object data, but I have no idea how to implement a test when it comes to a list of objects, I just need an example, someone could only show me an example…
-
1
votes1
answer49
viewsHow to change the logging level of a dependency?
I’m trying to deal with the logging level of a dependency, where it’s showing INFO and I would not like her to show that level, because the information is not pertinent, in my case is the logging…
-
1
votes1
answer705
viewsUnit Test Controller Spring with Mockito
I’m trying to test the method below my controller: @RequestMapping(value = "/listar", method = RequestMethod.GET) public ModelAndView iniciaTela(ModelAndView model, HttpServletRequest request){…
-
1
votes1
answer315
viewsUnit test (Junit and Mockito) - Clean & maintainable test code requires zero unnecessary code
I am writing the test of a findByID method(): public DoctorDTO getDoctorById(long id) throws DoctorNotFoundException { Optional<Doctor> doctorO = VerifyIfExists(id); return…
-
1
votes0
answers47
viewsChromedriver rebooting in all tests
Following a tutorial, my stepDefinitions page looks like this: @RunWith(DataDrivenTestRunner.class) @DataLoader(filePaths = "credenciaisv2.csv") public class CadastrarOLTTest { private WebDriver…
-
0
votes1
answer500
viewsHow to test the creation of an obj and method call in a Servlet?
I’m trying to create a web application using TDD, however, I’m having a question of how to test the Servlet that processes requests and calls due logic, I don’t know how to do the assert. @Test…
-
0
votes0
answers80
viewsAnt with Junitparams
Guys, I’m using ANT along with Jenkins to do the right continuous integration? I initially use ANT to run automated tests and then build the application. My problem boils down to running automated…
-
0
votes1
answer358
views -
0
votes1
answer3707
viewsHow to get the result of a Junit assertEquals test and put it into a String variable?
I have a Junit test case to test a single class. The class to be tested contains only one "sum" method that sums two numbers. To test if it is correct, I use the following method:…
-
0
votes1
answer242
viewsHow to compare two List<Float> in Junit?
I need to compare two Lists, assertEquals(lista1, lista2); Assert.assertTrue(lista1.containsAll(lista2)); And the error the test shows is (index:22 size:22) java.lang.Indexoutofboundsexception Until…
-
0
votes1
answer2564
viewsDoes anyone know how I can Scroll in Selenium Webdriver in JAVA
Code: WebElement emailsecundario = driver.findElement(By.id("RecoveryEmailAddress")); emailsecundario.sendKeys(" [email protected]"); WebElement gravar = driver.findElement(By.id("submitbutton"));…
-
0
votes1
answer2884
viewsHow to do Spring Boot unit test insert data into Database?
I created a simple system that is working perfectly, but I need to implement a unit test in Spring Boot, which happens that when I perform the test or I cannot enter the data in the database or…
-
0
votes0
answers16
viewsTest result window netbeans is not showing the tests
When I right click on a Maven project that contains Junit tests it shows the test results in the "default" output the same as the build result. I want it to show the tests in the test window and not…
-
0
votes1
answer47
viewsproblems using fail in junit
I want to create custom message for every exception error in my test class, my test is working perfectly, however when I purposely make a mistake it does not come within my exception as you can see…
-
0
votes0
answers55
viewsDynamically obtain jboss.server.data.dir "Operty"
I’m trying to test with junit in order to test if a directory can be created in the filesystem, to be able to test in all environments need to get the jboss 5.1 path dynamically via…
-
0
votes1
answer153
viewsModelling View Controller Unit Test with Mockite and Spring
I need to mount the unit test for the controller below (for example only): import javax.servlet.http.HttpServletRequest; import org.springframework.web.bind.annotation.GetMapping; import…
-
0
votes1
answer30
viewsinject CDI Beacons into during testing using Arquillian Chameleon
I’m unable to inject with CDI @Inject. The field movimentador If the contract is void. I believe it is because of Beans.xml, but how do I create Beans.xml using Maven-build-Deployment, because I am…
-
0
votes0
answers41
viewsUnit tests with Powermockrunner showing errors
I have two classes of tests that are run with PowerMockRunner and extending the class JdbcTest. Below follows their source code: Test class ScimImportUsersBusinessTest…
-
0
votes1
answer482
viewsJUNIT Eclipse - java.lang.Classnotfoundexception
All my tests using JUNIT no longer work. I tried unfortunately to remove all the /bin and some other configuration files. project .classpath. OK so far was already a lot of nonsense, then I tried to…
-
0
votes1
answer75
viewsHow to get access to methods onView, withId or Matches on Android?
I’m following this tutorial ! In it, displays this example: package com.example.android.testing.espresso.BasicSample; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import…
-
0
votes1
answer67
viewsPlay Framework TDD exception testing routes
I am studying the Play Framework with Java and in the documentation there is an example of route testing at the end of this page: Doc Play Framework But when trying to run the test he answers me…
-
0
votes1
answer270
viewsHow to use Junit with Demoiselle 2.4.2?
Hello I have a project with the following profile: Eclipse Luna Java 6 JSF 2.2/Primefaces 5.3 Jboss 7 Demoiselle 2.4.2. The application already works, the problem is in the execution of test cases…
-
0
votes1
answer133
viewsError: Runtimeexception when trying to mount test case
I’m trying to set up a simple test using espresso and the following errors appear: Code: import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import…
-
0
votes1
answer64
viewsCheck if it is the correct Fragment after the click (UI Test)
I would like a tip on how to check if it is the correct Fragment after the click Follow the thought (Wrong) for example, someone has an example of how I can test this? @RunWith(AndroidJUnit4.class)…
-
0
votes0
answers147
viewsSelenium with Maven plugin does not work the tests
Implementation to run a Junit and testNG test suite, When executed by the eclipse plugin, it works. By Maven no, the behavior of testNG tests, are changed, It seems that the http sessions do not end…
-
0
votes1
answer432
viewsNo bean named 'entityManagerFactory' available
I am testing my Spring application with Junit, however the error occurs after placing the annotation @EnableJpaRepositories: Caused by:…
-
0
votes1
answer274
viewsHow to integrate CDI-Unit with Jersey Test Framework?
Hello. I am working on a Ws Rest with CDI and Jersey. I want to create a test unit with Junit and due to CDI ended up using the CDI-Unit Runner. I found CDI-Unit simpler than Weldjunit4runner. Now,…
-
0
votes1
answer312
viewsClasses Parameterized with Junit 4
I have an exercise to solve involving classes parameterized in Java and I’m a little confused. The exercise is as follows: Program a parameterized class to test the method with the following input…
-
0
votes0
answers361
viewsHelp to catch the element by the Selenium xpath
Following code, I need help picking up element in Selenium: Elements name: j_username and name: j_password. <form method="POST" action="j_security_check" onsubmit="return(OnLoginSubmit());">…
-
0
votes0
answers100
viewsDoes not take elements with Selenium in Chrome
I’m trying to get elements from a page but it’s not found. Follow the code of the page: <form method="POST" action="j_security_check" onsubmit="return(OnLoginSubmit());"> <input…
-
0
votes1
answer87
viewsHow to implement Junit deletion with Spring Boot?
I need to know how to implement registration deletion through Junit(Unit Tests) with Spring Boot, I’m having difficulty, the inclusion is working as you can see below; @Autowired private…
-
0
votes2
answers688
viewsAre the Unitarian tests correct?
I am participating in a selection process, and one of the criteria is to implement any kind of unit test, I just wonder if it is implemented right the code below, it is working perfectly, I just…
-
0
votes0
answers33
viewsHow to have several exception classes in Spring Boot Junit?
I would like to have several exception classes in this code snippet below, but I’m only able to put one, as I do to put several exception classes? @Test(expected =…
-
0
votes1
answer45
viewsActivate Flash Player with Junit
good afternoon. I’m trying to enable Adobe Flash Player in Headless Chrome, but I’m not getting it. Follows my code: public class testes { @Test public void inicializa() { ChromeOptions options =…