Questions Tagged With unit-testhttps://answers.axonivy.com/tags/unit-test/?type=rssquestions tagged <span class="tag">unit-test</span>enThu, 09 Jan 2020 08:27:30 -0500Jacoco in Maven Buildhttps://answers.axonivy.com/questions/4312/jacoco-in-maven-build<p>Hello, I have been trying to get Jacoco to work with the maven build, because we used sonarqube to as part of our process and we need code coverage metrics. However, no matter what I do, Jacoco is always analyzing zero classes.</p> <p>Is there anything we can do for this?</p>TareqKThu, 09 Jan 2020 08:27:30 -0500https://answers.axonivy.com/questions/4312/jacoco-in-maven-buildmaventestciunit-testLosing resources folder when compiling ivy projecthttps://answers.axonivy.com/questions/2678/losing-resources-folder-when-compiling-ivy-project<p>Hi there,</p> <p>Currently, when I use maven to build the project I have this problem.</p> <p>I have 2 projects: <strong>desk_post</strong> and <strong>desk_post_test</strong> (required desk_post)</p> <p>When I run for desk_post</p> <p>-&gt; mvn clean install </p> <p>-&gt; successful </p> <p>-&gt; created: desk_post-1.00.08.00-SNAPSHOT.iar </p> <p>-&gt; the <strong>resources</strong> folder already included in <strong>iar</strong> file <img alt="alt text" src="http://answers.axonivy.com/upfiles/iar_file.png"></p> <p>Then I run for desk_post_test</p> <p>-&gt; mvn clean test -X</p> <p>-&gt; not successful</p> <p>I open the folder <strong>desk_post_test\target\ivyBuildApp\iarJars\</strong></p> <p>I can not find the <strong>resources</strong> anymore (see the picture) <img alt="alt text" src="http://answers.axonivy.com/upfiles/create_jar.png"></p> <p>Unfortunately, I have to use that resource </p> <p>I used: <strong>Ivy 6.3.0</strong></p> <p>Do you have any idea?</p> <p>This is one log in command line:</p> <pre><code>[INFO] Compiling ivy Project... [DEBUG] Create jar 'C:\work\finform_workspace\6.3\postfinance_desk\desk_post_test\target\ivyBuildApp\iarJars\desk_post-1.00.08.00-SNAPSHOT.jar' with java binaries from ivy archive 'C:\Users\vdkhanh\.m2\repository\ch\axonivy\finform\desk_post\1.00.08.00-SNAPSHOT\desk_post-1.00.08.00-SNAPSHOT.iar' </code></pre>khanh11166Wed, 07 Jun 2017 08:22:03 -0400https://answers.axonivy.com/questions/2678/losing-resources-folder-when-compiling-ivy-projectmavenunit-testjar504 Gateway Time-out on guidelines.axonivy.com/projects/guides/wiki/Continues_Integrationhttps://answers.axonivy.com/questions/2219/504-gateway-time-out-on-guidelines-axonivy-com-projects-guides-wiki-continues_integration<p><a href="https://guidelines.axonivy.com/projects/guides/wiki/Continues_Integration">https://guidelines.axonivy.com/projects/guides/wiki/Continues_Integration</a></p> <p>I'm looking to implement unit test, integration test and continuous integration so looking for guidelines, I thought I found it but look like the wiki is not working.</p>RemiMorinFri, 25 Nov 2016 19:31:00 -0500https://answers.axonivy.com/questions/2219/504-gateway-time-out-on-guidelines-axonivy-com-projects-guides-wiki-continues_integrationtestunit-testcibuildHow to use JPA entity manager instead of Ivy Entity Manager?https://answers.axonivy.com/questions/1102/how-to-use-jpa-entity-manager-instead-of-ivy-entity-manager<p>Hi everyone,</p> <p>Currently, I need to set up and use the JPA entity manager not Ivy Entity Manager because our team want it to work with JUnit. (Ivy Entity Manager doesn't work with JUnit because of Ivy environment).</p> <p>Is that possible to do so? I have tried edit the persistence.xml and try to create an entity manager but I've got the exception:</p> <pre><code>javax.persistence.PersistenceException: [PersistenceUnit: xrfl_unit] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at ch.soreco.standard.xrfl.service.TransactionManager.execute(TransactionManager.java:38) at ch.soreco.standard.xrfl.service.ValuationService.findAll(ValuationService.java:26) at ch.soreco.standard.xrfl.unittest.service.ValuationServiceTest.findAll(ValuationServiceTest.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.hibernate.service.jndi.JndiException: Error parsing JNDI name [XRFL] at org.hibernate.service.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:92) at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:63) at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1825) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1783) at org.hibernate.ejb.EntityManagerFactoryImpl.&lt;init&gt;(EntityManagerFactoryImpl.java:96) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) ... 31 more Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.getNameParser(Unknown Source) at org.hibernate.service.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:86) ... 45 more </code></pre> <p>If you have any idea or suggestion, please share with me.</p> <p>Thank You.</p>Tran Cuong TrucMon, 22 Dec 2014 03:47:09 -0500https://answers.axonivy.com/questions/1102/how-to-use-jpa-entity-manager-instead-of-ivy-entity-managerjpaunit-testhibernateUse the latest HSQLDB within my Projecthttps://answers.axonivy.com/questions/960/use-the-latest-hsqldb-within-my-project<p>I use an HSQLDB environment when my ivy Application is tested with Selenium Unit tests. The HSQLDB driver which is packed with ivy is the outdated version 1.8. With this version the <code>concat()</code> and <code>group_concat()</code> SQL functions are not (correctly) implemented and therefore some SQL statements can not be executed.</p> <p>I tried to use HSQLDB 2.3.2 by adding the jar <em>jre/lib/ext</em> folder and selecting the driver "other" within the "Databases Configuration Editor". But if I do that the Designer can no longer be started as the System-DB of the Designer relies on HSLDB 1.8.</p> <p>Is there any way to use a newer HSQLDB in my test environment?</p>SupportIvyTeamMon, 15 Sep 2014 16:12:54 -0400https://answers.axonivy.com/questions/960/use-the-latest-hsqldb-within-my-projectunit-testHow can Junit access to Ivy environment without EnvironmentNotAvailableExceptionhttps://answers.axonivy.com/questions/617/how-can-junit-access-to-ivy-environment-without-environmentnotavailableexception<p>Hello everybody I have two projects, one is A and one is A_Test. And i try to run JUnit Test case from project A_Test to test some functionalities of A. Here is a portion of code Project A</p> <pre><code>public CalendarEventRequest(){ this.organizer = **Ivy.var().get("xabs_calendarEvent_organizer").toString();** Calendar c = new GregorianCalendar(Ivy.session().getContentLocale()); this.timezone= c.getTimeZone(); } </code></pre> <p>Test case</p> <pre><code>@Test public void testCreateCalendarEvent002() throws Exception { CalendarEventRequest request = new CalendarEventRequest(); CalendarEventResult result = CalendarUtil.createCalendarEvent(request); assertNotNull(result); } </code></pre> <p>And JUnit threw this exception:</p> <pre><code> ch.ivyteam.ivy.environment.EnvironmentNotAvailableException: Access to ivy environment outside a process request thread is not possible. Current thread: Thread[main,5,main] at ch.ivyteam.ivy.environment.Ivy.getEnvironmentData(Ivy.java:455) at ch.ivyteam.ivy.environment.Ivy.var(Ivy.java:272) at ch.soreco.customers.xabs.bean.CalendarEventRequest.&lt;init&gt;(CalendarEventRequest.java:26) at ch.soreco.customers.xabs.bean.CalendarUtilTest.createRequestForOneDay(CalendarUtilTest.java:75) at ch.soreco.customers.xabs.bean.CalendarUtilTest.testCreateCalendarEvent002(CalendarUtilTest.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) </code></pre> <p>anyone can help me?</p>trungdvMon, 07 Apr 2014 09:34:02 -0400https://answers.axonivy.com/questions/617/how-can-junit-access-to-ivy-environment-without-environmentnotavailableexceptionenvironmentunit-testdesignerivyTest Drive Development for xIvy Projects?https://answers.axonivy.com/questions/589/test-drive-development-for-xivy-projects<p>Hi, </p> <p>i am wondering if there are tools to support TDD within an xIvy development cycle? My investigations in this area brought no valuable results. </p> <p>What i am looking for is the possibility to write the test scenarios for functional processes and automatic test runner to perform the tests on demand or triggered by kind of events (deployment on the server, check in to the version control system etc.)</p> <p>Any ideas to increase test coverage of the xIvy projects (it is near zero at the time) are welcome.</p> <p>Best regards, </p> <p>Mikhail Galyutin.</p>mgalyutinWed, 26 Mar 2014 10:48:45 -0400https://answers.axonivy.com/questions/589/test-drive-development-for-xivy-projectsunit-testSolution: How to Unit-Testhttps://answers.axonivy.com/questions/166/solution-how-to-unit-test<p>Hi there</p> <p>I twiddled a bit and found a solution how to unit-test. It is not the fancy graphical way but there is all you need and it is fairly customizable.</p> <ol> <li>Create a new business-process </li> </ol> <p><img alt="Workflow" src="http://s24.postimg.org/58g8l9gn9/Workflow.jpg"></p> <ol> <li>Create a execution listener <br> Download: <a href="http://www.file-upload.net/download-8362431/ExecutionListener.java.html">ExecutionListener</a></li> <li>Create the Testrunner class <br> Download: <a href="http://www.file-upload.net/download-8362430/UnitTestRunner.java.html">UnitTestRunner</a></li> </ol> <p>How the result may look like: </p> <p><img alt="alt text" src="http://s8.postimg.org/752yicuph/Output.jpg"></p> <p>Resources:</p> <pre><code> [1]: http://s24.postimg.org/58g8l9gn9/Workflow.jpg [2]: http://www.file-upload.net/download-8362431/ExecutionListener.java.html [3]: http://www.file-upload.net/download-8362430/UnitTestRunner.java.html [4]: http://s8.postimg.org/752yicuph/Output.jpg </code></pre>Daniel OechslinWed, 04 Dec 2013 09:07:18 -0500https://answers.axonivy.com/questions/166/solution-how-to-unit-testunit-test