unit testing - Java HeadlessException? -
i'm trying unit test java gui source code in eclipse.
when execute unit test junit, of test succeed.
however, encountered small exception in sonarqube report tests successful in eclipse reported failed.
exception messages here.
no x11 display variable set, program performed operation requires it. java.awt.headlessexception: no x11 display variable set, program performed operation requires it. @ java.awt.graphicsenvironment.checkheadless(graphicsenvironment.java:207) @ java.awt.window.<init>(window.java:536) @ java.awt.frame.<init>(frame.java:420) @ javax.swing.jframe.<init>(jframe.java:233) @ com.kaist.se.pmpdaemon.mainframe.<init>(mainframe.java:56) @ com.kaist.se.pmpdaemon.mainframetest.testsetmaintext(mainframetest.java:80) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:50) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12) @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:47) @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:17) @ org.junit.internal.runners.statements.runbefores.evaluate(runbefores.java:26) @ org.junit.internal.runners.statements.runafters.evaluate(runafters.java:27) @ org.junit.runners.parentrunner.runleaf(parentrunner.java:325) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:78) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:57) @ org.junit.runners.parentrunner$3.run(parentrunner.java:290) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:71) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:288) @ org.junit.runners.parentrunner.access$000(parentrunner.java:58) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:268) @ org.junit.internal.runners.statements.runbefores.evaluate(runbefores.java:26) @ org.junit.internal.runners.statements.runafters.evaluate(runafters.java:27) @ org.junit.runners.parentrunner.run(parentrunner.java:363) @ org.apache.maven.surefire.junit4.junit4testset.execute(junit4testset.java:53) @ org.apache.maven.surefire.junit4.junit4provider.executetestset(junit4provider.java:123) @ org.apache.maven.surefire.junit4.junit4provider.invoke(junit4provider.java:104) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ org.apache.maven.surefire.util.reflectionutils.invokemethodwitharray(reflectionutils.java:164) @ org.apache.maven.surefire.booter.providerfactory$providerproxy.invoke(providerfactory.java:110) @ org.apache.maven.surefire.booter.surefirestarter.invokeprovider(surefirestarter.java:175) @ org.apache.maven.surefire.booter.surefirestarter.runsuitesinprocesswhenforked(surefirestarter.java:107) @ org.apache.maven.surefire.booter.forkedbooter.main(forkedbooter.java:68)
what should do?
you have move sonar/test server same environment run - windows in case. see, awt uses platform gui environment. so, takes graphical parts system. in other words - label on windows looks different on mac , different on unix. in last case unix may have no graphical environment @ , have no label too. headless allows compile , run "graphical" environment without platform support.
Comments
Post a Comment