junit

Monospace font for junit in eclipse?

微笑、不失礼 提交于 2019-12-20 02:06:10
问题 How can I change the font in the JUnit tab so that it displays the results using a monospaced font? 回答1: I am using Groovy, I have found the solution here. You need to go to Groovy>Preferences and check the use monospace font checkbox. 来源: https://stackoverflow.com/questions/12348238/monospace-font-for-junit-in-eclipse

Android Robotium - How to manage the execution order of testcases?

喜你入骨 提交于 2019-12-19 20:00:11
问题 I am trying to use Robotium to automate the testing of an application. The test cases were documented and they are supposed to be test in specific order. But it seems that Junit run the tests in alphabetic order.. how do I rearrange the order of execution? Here is the basic structure of my test class: public class ETTerminalTest extends ActivityInstrumentationTestCase2<IdleActivity> { private Solo solo; private static final Logger LOGGER = LoggerFactory.getLogger(ETTerminalTest.class); public

Android Robotium - How to manage the execution order of testcases?

元气小坏坏 提交于 2019-12-19 20:00:07
问题 I am trying to use Robotium to automate the testing of an application. The test cases were documented and they are supposed to be test in specific order. But it seems that Junit run the tests in alphabetic order.. how do I rearrange the order of execution? Here is the basic structure of my test class: public class ETTerminalTest extends ActivityInstrumentationTestCase2<IdleActivity> { private Solo solo; private static final Logger LOGGER = LoggerFactory.getLogger(ETTerminalTest.class); public

How do I mock a private field using PowerMockito? [duplicate]

老子叫甜甜 提交于 2019-12-19 12:01:41
问题 This question already has answers here : How do I test a private function or a class that has private methods, fields or inner classes? (51 answers) Closed last year . The solution proposed as a duplicate is not a PowerMockito solution and as a consequence does not answer this question. Further, this question IS answered legitimately below. IDK if this is a duplicate or not but I sure can't find the item in question if it is. I keep expecting this to be really simple, since it is pretty

XPath or CSS in Selenium RC with Java is not working

爱⌒轻易说出口 提交于 2019-12-19 11:34:18
问题 I am trying to automate the following scenario with selenium RC: Open Google home page and enter "Software" in search box and then click on search button. Click on the first link of multiple links retrieved by Google search. As I don't see either name or id attributes for these links and as this link's content is dynamic, I am trying to use XPath or CSS. From Firebug, I got XPath and also CSS by right clicking then copy XPath, copy CSS. XPATH:/html/body/div[2]/div/div/div[6]/div[2]/div/div[2]

Determining which test cases covered a method

若如初见. 提交于 2019-12-19 10:43:10
问题 The current project I'm working on requires me to write a tool which runs functional tests on a web application, and outputs method coverage data, recording which test case traversed which method. Details: The web application under test will be a Java EE application running in a servlet container (eg. Tomcat). The functional tests will be written in Selenium using JUnit. Some methods will be annotated so that they will be instrumented prior to deployement into the test enviornment. Once the

@Autowired annotation not able to inject bean in JUnit class

佐手、 提交于 2019-12-19 10:17:17
问题 my test class: public class myTest extends TestCase{ @Autowired BeanClass beanObject public void beanTest() { Classdata data = beanObject.getMethod(); } } I am getting a null pointer exception at line: Classdata data = beanObject.getMethod(); the beanObject.getMethod(); precisely gives nullpointer exception How should i make possible the autowiring of the field beanObject in my Junit class so that i can use the methods from the "BeanClass" class? Copied from Comments: in plain terms..

Spring 5 with JUnit 5 + Mockito - Controller method returns null

一个人想着一个人 提交于 2019-12-19 10:09:22
问题 I try to test a method named as loadData defined in MainController which returns result as a string. Despite that this method actually returns data when the web app runs on servlet container (or when I debug the code), no data returns when I invoke it from a test class based on JUnit 5 with Mockito . Here is my configuration: @ContextConfiguration(classes = {WebAppInitializer.class, AppConfig.class, WebConfig.class}) @Transactional @WebAppConfiguration public class TestMainController {

What is the best way to test that a spring application context fails to start?

谁说胖子不能爱 提交于 2019-12-19 10:09:14
问题 I use the spring-boot-starter-web and spring-boot-starter-test. Let's say I have a class for binding configuration properties: @ConfigurationProperties(prefix = "dummy") public class DummyProperties { @URL private String url; // getter, setter ... } Now I want to test that my bean validation is correct. The context should fail to start (with a specfic error message) if the property dummy.value is not set or if it contains an invalid URL. The context should start if the property contains a

Spring testing and maven

这一生的挚爱 提交于 2019-12-19 09:53:50
问题 I'm trying to test my Spring web app but i have some problems. I added a test class in my maven @RunWith( SpringJUnit4ClassRunner.class ) @ContextConfiguration public class UserServiceTest { @Autowired private UserService userService; @Test public void testName() throws Exception { List<UserEntity> userEntities = userService.getAllUsers(); Assert.assertNotNull(userEntities); } } But i got a NullPointerException on userService when i try to run this test. IntelliJ say "Could not autowire. No