junit

JMockit javaagent isn't initializing JMockit

回眸只為那壹抹淺笑 提交于 2019-12-22 10:48:29
问题 I've set up JMockit for use with some JUnit tests also using Robolectric, but I am getting errors. I'm primarily using maven to run the tests. When I run the test with mvn test and the javaagent configured as specified here I get the usual exception: java.lang.IllegalStateException: JMockit wasn't properly initialized; check that jmockit.jar precedes junit.jar in the classpath (if using JUnit; if not, check the documentation) I have validated that JMockit is on the classpath before JUnit

Jenkins test result parsing

馋奶兔 提交于 2019-12-22 10:30:56
问题 I've got a Jenkins with a lot of jobs. These jobs do tests and produce test outputs in XML. Those XML test results look - pretty standard - like this: <testsuites name="testsuitesname"> <testsuite name="testsuitename"> <testcase classname="classname" name="testcasename"> blabla </testcase> </testsuite> </testsuites> When you use the Post-build action Publish JUnit test result report (found on the configuration page of a job) the structure of those published results of a build (in Jenkins)

Issue with EJB 3.1 injected with CDI bean while running JUnit

回眸只為那壹抹淺笑 提交于 2019-12-22 10:25:09
问题 I created a EJB3.1 and injected CDI bean using the @inject but facing some issues while unit testing however when tested from the servlet its working fine. I have the beans.xml in the WEB-INF folder. Below is my EJB code: @Stateless public class CdiUsingEjb { @Inject private HelloServletCDIPojo helloServletCDIPojo; public String greet() { assert helloServletCDIPojo != null; return helloServletCDIPojo.from(); } } Below is my CDI bean: public class HelloServletCDIPojo { public String from() {

Given a choice of adding unit tests or integration tests to an existing system, which is better to start with and why?

拟墨画扇 提交于 2019-12-22 10:19:10
问题 I'm currently consulting on an existing system, and I suspect the right next step is to add unit tests because of the types of exceptions that are occurring (null pointers, null lists, invalid return data). However, an employee who has a "personal investment" in the application insists on integration tests, even though the problems being reported are not related to specific use cases failing. In this case is it better to start with unit or integration tests? 回答1: Typically, it is very

Issue with EJB 3.1 injected with CDI bean while running JUnit

大憨熊 提交于 2019-12-22 10:18:47
问题 I created a EJB3.1 and injected CDI bean using the @inject but facing some issues while unit testing however when tested from the servlet its working fine. I have the beans.xml in the WEB-INF folder. Below is my EJB code: @Stateless public class CdiUsingEjb { @Inject private HelloServletCDIPojo helloServletCDIPojo; public String greet() { assert helloServletCDIPojo != null; return helloServletCDIPojo.from(); } } Below is my CDI bean: public class HelloServletCDIPojo { public String from() {

Mock a private method of the class under test in JMockit

穿精又带淫゛_ 提交于 2019-12-22 09:15:14
问题 In my class under test (CUT) - an ejb - I have a private method "getConnection". I want to test another method of the CUT but this method will fail before hand. I tried it like shown below, but "invoke" is wrong. I don't want to invoke the method, I want to stub it. But how? ('connection' is a stub) new NonStrictExpectations() { { invoke(archivingBean, "getConnection");result = connection; } }; archivingBean.moveCreditBasic2Archive(new Date()); 回答1: Your test is correct, except that it's

Method myLooper in android.os.Looper not mocked with Coroutines

非 Y 不嫁゛ 提交于 2019-12-22 08:48:15
问题 I want to do some test of coroutines in JUnit but I met some problems. Code is easy: @Test fun coroutineTest() { //runBlocking(Unconfined) doesnt work too runBlocking () { delay(1000) println("test") } } But I got that error java.lang.RuntimeException: Method myLooper in android.os.Looper not mocked. See http://g.co/androidstudio/not-mocked for details. at android.os.Looper.myLooper(Looper.java) at kotlinx.coroutines.experimental.android.MainLooperChecker.checkRunBlocking(HandlerContext.kt

Can you mix TestNG and JUnit Assertions together within the same Test / Framework?

六月ゝ 毕业季﹏ 提交于 2019-12-22 08:44:32
问题 Can you mix TestNG and JUnit Assertions together within the same Test / Framework? For example lets say I have developed a framework, is it possible to have the following: A TestNG class which uses JUNit Assertions A TestNG which uses both Junit and TestNG assertions? Thanks For your help 回答1: I think the short answer is no. If you notice when you mark a method as a test with the @Test annotation you are prompted which framework to import. Same thing witht the assertions as well. Think about

Why does Cobertura report 0% coverage when run through the Eclipse plugin?

狂风中的少年 提交于 2019-12-22 08:43:57
问题 (There are a tonne of these questions, but all the ones I can find relate to Maven. Before you suggest this one is a duplicate, please understand that this doesn't relate to Maven in any way.) I am using Cobertura within Eclipse to determine my percentage of code covered by my JUnit tests. All 99 of my unit tests run successfully, both within and outside of Cobertura, but Cobertura reports back that they have covered 0% of my code. I : am running Cobertura through the Eclipse plugin am using

Mockito - Mock not being injected for one of the testcases

故事扮演 提交于 2019-12-22 08:38:34
问题 I have a jsf spring application and using mockito for my unit test. I keep getting NullPointerException when i run my junit test in iEmployeeService mocking. There are not Exception for iSecurityLoginService . Method to be mocked @Autowired IEmployeeService iEmployeeService; @Autowired ISecurityLoginService iSecurityLoginService; public void addEvent() { entityEventsCreate.setTitle(entityEventsCreate.getTitle()); entityEventsCreate.setModifiedBy(iSecurityLoginService .findLoggedInUserId());