junit

Selenium 3.0 ExpectedConditions issue

感情迁移 提交于 2019-12-24 01:59:28
问题 Using a click() implementation as follows, selenium will act as if it clicked the button, and will expect the next screen. But the webpage will not receive the click so the next screen will not pop up. I don't really understand what it is going on, maybe some of you encountered this issue before. Here's the click implementation: public static void click(WebDriver driver, By by) { new WebDriverWait(driver, DEFAULT_WAIT_FOR_ELEMENT) .until(ExpectedConditions.elementToBeClickable(by)) .click();

Spring dependency injection null when running a test case

ⅰ亾dé卋堺 提交于 2019-12-24 01:55:08
问题 I'm working with Spring 3.0 and jUnit 4.8 and I'm trying to develop some unit test . In fact, I'm only trying to set a property (a file) of a bean using dependency injection in a test case definined in the XML loaded in the application context used by the jUnit. I'm using an XML file configuration loaded using the annotation for jUnit 4 aproach. This is the main BaseTest that all test classes used: @ContextConfiguration("/test-context.xml") @RunWith(SpringJUnit4ClassRunner.class) @Ignore

Getting list of tests from JUnit command line

吃可爱长大的小学妹 提交于 2019-12-24 01:27:22
问题 My problem, in short, is that I want to run some JUnit tests from a command line and I would like to be able to see: A list of all tests (whether they ran or not). A list of all tests which passed. A list of all tests which failed The reason for the first bullet, is because I believe if one test calls System.exit, the others won't run, I still want to know about these tests, even if they didn't run. Lets say I have this test class: import junit.framework.TestCase; public class ALoadOfTests

How does JUnit find the eclipse plug-in being tested?

我是研究僧i 提交于 2019-12-24 01:23:49
问题 I am writing a plug-in (ClassRefactoringPlugin) that examines source code in Eclipse 3.6.1. The plug-in contains a CallData class that examines a Java source file and figures out which Java elements are called from a method using JDT operations. I wrote a JUnit 4 test for this class that also resides in the ClassRefactoringPlugin project. When I ran it as a JUnit plug-in test, I got: Java Model Exception: Java Model Status [ClassRefactoringPlugin does not exist] What have I done wrong? The

Problem using MockRoundtrip class

时间秒杀一切 提交于 2019-12-24 01:23:36
问题 I have following code: @Test public void testSaveValid() throws Exception { MockRoundtrip trip = new MockRoundtrip(mockServletContext, ContactFormActionBean.class, mockSession); trip.setParameter("contact.email", "test@test.com"); trip.setParameter("contact.phoneNumber", "654-456-4567"); trip.execute("save"); ContactFormActionBean bean = trip.getActionBean(ContactFormActionBean.class); assertEquals(0, bean.getContext().getValidationErrors().size()); PhoneNumber pn = bean.getContact()

Injection of autowired dependencies failed when trying to create a test

独自空忆成欢 提交于 2019-12-24 01:17:09
问题 I am trying create a junit test for a repository and I am getting this nice exception. Full Exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gov.mt.dphhs.sdnh.core.domain.RepositoryJDBCTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: gov.mt.dphhs.sdnh.core.domain.impl.RepositoryJDBC gov.mt.dphhs.sdnh.core.domain.RepositoryJDBCTest

Unit testing method that invokes FileWriter

六眼飞鱼酱① 提交于 2019-12-24 01:05:12
问题 I'm trying to write a unit test for a method that calls a FileWriter. I am using JUnit 4.8, Powermock and Mockito. The method I'm testing looks like this. public void methodToTest(String fileName, String text){ File file = new File (someStaticString) //string is a static field of the class and the path is a dir if(!file.exist()){ //create dir} try{ FileWriter fw = new FileWrite(file.getAbsolutePath() + "/" fileName, true); fw.write(text); fw.close(); } catch(Exception e){ e.printStackTrace }

Configure JNDI names with Open EJB

不问归期 提交于 2019-12-24 00:48:55
问题 I'm trying to (unit) test my EJB class without having to startup my websphere environment. Now I'm using Open EJB, but there are some issues with resolving the JNDI Names for other EJBs that are used within my EJB... and there is no way for me to inject mocked classes from my test right now. Getting the InitialContext final Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); properties

ClassCastException when using embedded glassfish for unit tests

人走茶凉 提交于 2019-12-24 00:34:52
问题 I'm running some unit tests on some EJBS via maven and an embedded glassfish container. One of my tests works, but all subsequent attempts to test a different EJB result in the same error: java.lang.ClassCastException: $Proxy81 cannot be cast to Followed by whatever bean I'm attempting to test. I'm confident my setup is good since, as I say, one of my beans can be tested properly. Examples of workiing code: @Stateful public class LayoutManagerBean implements LayoutManager { private final Log

How to add a href links in <system-out> or <failure> tags in Jenkins/JUNIT xml

六眼飞鱼酱① 提交于 2019-12-24 00:23:45
问题 I have integrated Jenkins to C unit test library and I am parsing the output and generating XML in the schema that the jenkins understands. while generating the xml output, I just show the gist of the errors reported, and I would like to create a link to where the actual logs are located so that the user can click on teh link in jenkins to view the actual file. I am unable to add the HTML tags under this XML. The Jenkins turns them into encoded <.. and makes my link useless. I even try to use