PHPUnit is Working With Command Line, but not with Eclipse - eclipse

Whenever I run a test file from eclipse it works and display result as:
. 1/1 (100%)
Time: 371 ms, Memory: 8.00MB
OK (1 test, 1 assertion)
But If I run the same test from the Eclipse Oxygen, I get the error:
PHP Fatal error: Declaration of PHPUnitLogger::addFailure(Test $test, AssertionFailedError $e, $time): void must be compatible with PHPUnit\Framework\TestListener::addFailure(PHPUnit\Framework\Test $test, PHPUnit\Framework\AssertionFailedError $e, float $time): void in /tmp/phpunit_printer/PHPUnitLogger.php(415) : eval()'d code on line 1
I downloaded phpunit-7.1.phar, and installed it globally by making it executable and moving it to /usr/local/bin and for Eclipse, I have downloaed in the Download directory and without making it executable I added it into my Eclipse Project as an External Phar but it is not working and giving the above error.
Can someone help me fixing the issue?
By the way, I am a NetBeanse User, but NetBeans is not supporting PHP7.1 that's why moving to Eclipse.
UPDATE
Here is my test file:
<?php
namespace tests\Unit\;
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase
{
public function testSimple() {
$this->assertEquals(1, 1);
}
}

I had exactly the same problem with PHPUnit 7.5.14 and didn't find a solution.
Since I wanted to test my application running with PHP 7.1, I decided to try PHPUnit 6 and it worked at once. So PHPUnit 6.5.14 did the trick for me.
It seems Eclipse is not compatible with PHPUnit 7. My Eclipse Version is 2018-12 (4.10.0) with PDT 6.2. After switching to PHPUnit 6 other problems (that I managed to find workarounds for) were gone too. For example the generated class code overrides TestCase::__construct without calling the parent constructor. It seems to be a problem with PHPUnit 7, not so with 6.
I didn't find a compatibility chart of Eclipse PDT to support my thesis.

Related

Error in running a plugin in imageJ

I am using imageJ (Fiji) version: 2.0.0-rc-43/1.50e
I installed a IHC_Profiler (https://sourceforge.net/projects/ihcprofiler/)
And when I run it, it shows a console with this:
Compiling 1 file in
/var/folders/k2/kdrnsbws5gz8vrt83yjmlbdm0000gn/T/java744586229414007803
/var/folders/k2/kdrnsbws5gz8vrt83yjmlbdm0000gn/T/java744586229414007803/src/main/java/IHC_Profiler.java:10: cannot access java.lang.Object
bad class file:
ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)]
class file has wrong version 52.0, should be 50.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
public class IHC_Profiler implements PlugIn {
When I use imageJ 1.48 version, it is okay. I wonder if this problem can be solved?
You are running Fiji with Java 8, but without the Java-8 update site enabled.
The easiest solution is to download a fresh Fiji, which comes with the Java-8 update site enabled out of the box.
See this guide for details:
http://imagej.net/2016-05-10_-_ImageJ_HOWTO_-_Java_8,_Java_6,_Java_3D

PHP Fatal error: Class 'RemoteWebElement' not found in

I have a symfony project that run normal in command line:
php app/console server:run
But, I want to run inside PhpStorm. When I try to do this, it gives the fatal error:
PHP Fatal error: Class 'RemoteWebElement' not found in
I already tried to look the oficial documentation of the classe:
http://facebook.github.io/php-webdriver/classes/RemoteWebElement.html. But I didn't found information that culd help me.
I also added the compose dependency:
composer require facebook/webdriver
But had no effect!
=======================================
I'll explain step-step how to get this the bug (It will be very long!):
I have:
PHP 5.5.9
PhpStorm 10.0.3
composer 1.0-dev (7117a5775ffdcdfd31bbd52a138a6f9c65e7e3c2) 2016-02-03
So, create a new symfony project (current version 3.0) and add composer dependencies:
symfony new project
cd project
composer update
Then, open this project inside of phpstorm and I configure settings for to run the project:
Settings -> Languages & Frameworks -> PHP
"PHP language level": 5.5
"Interpreter": 5.5.9
Add through plus(+) the PHP folder:
/usr/share/php
Click 'OK'
Now, try to run de project through PhpStorm by the shortcut:
Ctrl+Shif+F10.
Will appear the bug:
PHP Fatal error: Class
'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in
Solve this by this way inside of PhpStorm:
Settings -> Languages & Frameworks -> PHP -> PHPUnit
Choose: "Use custom autoloader"
And, in the field "Path to script", informe the autoloader's address. For example:
/home/murilo/git/slu/app/autoload.php. Click 'OK'.
Again, try to run de project through PhpStorm by the shortcut:
Ctrl+Shif+F10
Will appear the bug:
PHP Fatal error: Class 'Doctrine\Tests\Common\Cache\CacheTest' not
found in
Solve this through this command inside the project folder:
composer require maslosoft/cachetest:dev-master -n --no-progress
For the last time, try to run de project through PhpStorm by the shortcut:
Ctrl+Shif+F10
Will appear the bug:
PHP Fatal error: Class 'RemoteWebElement' not found in
I'm at this bug.
Please, someone knows how I can overcome this bug? o.O
I struggled with the same exact issue as you have described. After breaking my head for most of the day with this problem, I found the issue.
When you execute the command php app/console server:run in command line, it sets up a server and runs the website. However, when you run the project in PHPStorm, it doesn't actually run it as a server but runs it as a PHPUnit. What you need to do is configure a PHP Web Application in PHPStorm and run that.
Check the image below where I have configured the website. When I run the Web Application, it will run by the url and it will show up in your browser.

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script7.groovy: 1: unable to resolve class

I am currently receiving this error when trying to run a soapui file:
org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed: Script7.groovy: 1: unable to resolve class com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate # line 1, column 1.
import com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate # line 1, column 1.
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:148)
at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1206)
at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:148)
at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:585)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:832)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:495)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:472)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:292)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:727)
at groovy.lang.GroovyShell.parse(GroovyShell.java:739)
at groovy.lang.GroovyShell.parse(GroovyShell.java:766)
at groovy.lang.GroovyShell.parse(GroovyShell.java:757)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:141)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:90)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
1 error
soapUI code:
import com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate
def env = testRunner.testCase.testSuite.project.getPropertyValue("env")
def baseUrl = testRunner.testCase.testSuite.project.getPropertyValue("baseUrl")
log.info("The baseurl is "+baseUrl)
log.info("The env under test is "+env)
SoapUI_T11001_StockConsSecurityCurBusiDate testStep = new SoapUI_T11001_StockConsSecurityCurBusiDate();
testStep.init(baseUrl);
testStep.execute(null);
eclipse code:
package com.company.ui.test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.eviware.soapui.model.support.AbstractSubmitContext;
import com.eviware.soapui.model.testsuite.TestRunner;
public class SoapUI_T11001_StockConsSecurityCurBusiDate extends BaseSelenium{
public static void main(final String[] args){
final SoapUI_T11001_StockConsSecurityCurBusiDate ico = new SoapUI_T11001_StockConsSecurityCurBusiDate();
try{
ico.init("https://avncedevn1.nam.nsroot.net:17620/", false);
}catch(Exception e){
// TODO Auto-generated catch block
e.printStackTrace();
}
ico.execute(null);
}
//...code....
}
how do I solve this error ? I'm not sure what is causing the error.
This work for me:
Press Ctr+Alt+Shift+s
or:
From File menu -> Project Structure -> SDK Location -> JDK location Drop down menu choose:
Embeded JDK c:....\jre
Then ok.
If you using android studio and got this error then I solved it changing the Gradle version of the project to the newest version 6.2.1 on the project structure options.
One of the possible reasons is that the jdk version is too high. For example, using jdk 16 to build the source code of Apache Kafka throws this error. Using jdk 11 is fine.
bild.gradel file in change clashpath
dependencies {
classpath "com.android.tools.build:gradle:7.0.1"
}
gradel-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
I'm Using Android Studio - Arctic Fox and this worked for me
Go To File menu -> Project Structure -> SDK Location -> Gradle Setting
Then check the "Download external annotations for dependencies" button and select JDK location from the drop down menu and choose: Android Default Jdk Vesion.
Click on Ok.
If you wanted to make a new project on Android Studio after first install, probably you write your application name including (') sign as called apostrophe.
For Example, I tried to set a name as: "Henry's Game" but apostrophe caused Android Studio to not load because of this mistake:
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
So, just change your application's name, and simply use Latin alphabet languages such as English.
To fix: Go to your Android Project Tree and find Gradle Scripts > settings.gradle > change the name:
rootProject.name='Henry Game'
include ':app'
With Eclipse Juno (Kepler Release) Build id: 20121114-2344, I found similar problem:
org.codehaus.groovy.control.multiplecompilationerrorsexception startup failed unable to resolve class Chart
The class Chart is my container class for some utilities for charting.
I tried outside of Eclipse, with Groovy 2.0 Console the same code segment works fine. After scratching my head for about 3 hours, I resolved it by adding the following
import excel.Chart
in the invoking class with main() that has "new Chart()" thus getting the complaints, once added, the error is gone. Even more weird, after passing the error, I remove that import, there is still no more complaints! (All my scripts/classes are under the same package excel, I suppose such import statement is not needed.)
One of the symptom of the complaints is that there was not Chart.class generated in the output bin folder. Once the complaints gone, Chart.class appeared there.
I guess that it might be a bug of Eclipse/Groovy plugin (I use Groovy Plugin for Juno).
Hope my understanding is correct, and it helps.
The solution for me was change the gradle version and the Gradle JDK:
File > Project Structure > Project
enter image description here
File > Project Structure > SDK Location
enter image description here
Go to Files and click Invalidate caches/ Restart . Android studio will clear the cached and it will be restarted without any error.
Hope this answer helps you :)
For this problem, you might also encounter package naming from gsp as I did. In the build/gsptmp folder, Grails 4.x.x creates temporary gsp files to link the classes that they refer to. Due to the change of a package name it was failing to do so in my case. Try with command grails war --stacktrace during war build!
Previously, it was <%# page import="bv.BankReconciliationController" %>
but the folder bv was renamed to factoring.
So, the solve was to change the import to
<%# page import="factoring.BankReconciliationController" %> and it worked :)
I have also faced the same and tried all of the solution here and other places as well, at last i deleted my .gradle and gradle both folder and caches of android studio and open the studio again and rebuild the project, it's works after that fine and used the latest gradle version and previously it was picking up the older version and causing issues.
for me , solution is to upgrade the gradle to latest version , and remove the .idea file , and invalidate caches and restart android studio.
When starting a project make sure to select SDK version 11 or later. It will default to a minimum SDK but you have to scroll down to a later version for it to work. Then the project should load and build.
For me, I just delete the .grade file under program files(C:\Users\username\ .gradle) in windows and it will work.
This work for me:
From File menu -> Project Structure -> SDK Location -> klik Gradle Setting for show hide menu, Gradle JDK choose:
Embeded JDK c:....\jre
Then ok.
Do you have the grail and groovy plugin installed? If so try uninstalling this plugin. I had the same error message and uninstalling the plugin, restart IDE worked for me.

Why would Eclipse not be able to include a file when running a PHPUnit test?

I have the following class and unit test in a PHP project in Eclipse:
I know my unit test works as I can run it at the command line:
Now I want to run this test from Eclipse. I set up PHP Unit in Eclipse like this:
However, when I run the PHPUnit tests:
It tells me that it can't include the class file:
/usr/bin/php -c /var/folders/UA/UAv38snBHd0QMgEPMCmM9U+++TM/-Tmp-/zend_debug/session4910937990995915704.tmp -d asp_tags=off /Applications/eclipse/plugins/org.phpsrc.eclipse.pti.tools.phpunit_0.5.0.R20101103000000/php/tools/phpunit.php --log-junit /var/folders/UA/UAv38snBHd0QMgEPMCmM9U+++TM/-Tmp-/pti_phpunit/phpunit.xml /Volumes/data/domains/et/extjslayout/phpunittest/tests
PHP Warning: include_once(../Product.php): failed to open stream: No such file or directory in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 3
PHP Warning: include_once(): Failed opening '../Product.php' for inclusion (include_path='/usr/local/PEAR') in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 3
PHP Fatal error: Class 'Product' not found in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 9
Why would PHPUnit be able to find the class when run from the command line but not when run from Eclipse?
When you start something from the command line, the "current directory" has a well-defined meaning: It's the directory where you started the command.
In Eclipse, what is the "current directory"? It's probably the directory from which you started Eclipse or maybe the folder in which Eclipse is installed.
I haven't used PHP in Eclipse before but for other languages, I can set the current directory in the launch config somewhere. If that doesn't work, define a variable which points to your project and then use absolute paths (using that variable as a starting point).
Have same problem. Found only solution by creating tests with internal PHPUnit wizard like at this screenshot:
Source: HowTo create a Test Case Class from a PHP Class
But following investigate show that your test case file should contain reference to tested code for example like this: require_once 'C:\Apache2\htdocs\jobeet\src\Ibw\JobeetBundle\Utils\Jobeet.php';
Other experiments with plugin config not bringing luck. So in my opinion PHPUnit from PHP Tools not well developed plugin. Consider using MakeGood plugin as better alternative.

Findbugs using jsr305 annotations in eclipse is not finding bugs

I've been experimenting with the jsr 305 annotations for use with Findbugs, specifically the #CheckForNull annotation which would have avoided a bug I just found making it out to customers. I've added jsr305.jar and annotations.jar to my build path but the bugs aren't found by findbugs. I'm using Eclipse with the Eclipse Findbugs plugin. Below is some sample code which shows the same bug but doesn't when I run findbugs over it find the bug. I have tried this in Eclipse Galileo and Ganymede.
public class FindBugsAnnotationsTest {
ArrayList<String> canBeNull;
#CheckForNull
public List<String> getCanBeNull() {
return canBeNull;
}
public void shouldGetFindbugsWarning() {
canBeNull.add("a string");
getCanBeNull().add("a string");
}
}
This may be obvious, but I think your issues are with Eclipse (perhaps the FindBugs plugin in particular), not FindBugs itself.
You might consider running FindBugs from the command line to eliminate any Eclipse issues and ensure that you have FindBugs running correctly in its own. Knowing how to run FindBugs in a standalone mode will give you a fallback when your IDE is not configured properly.
I saved your source code in a file named FindBugsAnnotationsTest.java, added imports for List, ArrayList, and CheckForNull, compiled, and ran FindBugs 1.3.9. FindBugs generates several warnings about null values:
M D NP: Possible null pointer dereference in FindBugsAnnotationsTest.shouldGetFindbugsWarning() due to return value of called method Dereferenced at FindBugsAnnotationsTest.java:[line 18]
M C UwF: Unwritten field: FindBugsAnnotationsTest.canBeNull At FindBugsAnnotationsTest.java:[line 12]
M C NP: Read of unwritten field canBeNull in FindBugsAnnotationsTest.shouldGetFindbugsWarning() At FindBugsAnnotationsTest.java:[line 16]
Warnings generated: 3
These are the imports I added to the top of FindBugsAnnotationsTest.java:
import java.util.ArrayList;
import java.util.List;
import edu.umd.cs.findbugs.annotations.CheckForNull;
Commands:
javac -d . -classpath ${FINDBUGS_HOME}/lib/findbugs.jar FindBugsAnnotationsTest.java
${FINDBUGS_HOME}/bin/findbugs FindBugsAnnotationsTest.class
Where ${FINDBUGS_HOME} is the directory in which Findbugs 1.3.9 is installed. javac is assumed to be on the path.
Note: I used the findbugs.jar instead of annotations.jar and jsr305.jar but I get the same results with this command:
javac -d . -classpath ${FINDBUGS_HOME}/lib/annotations.jar:${FINDBUGS_HOME}/lib/jsr305.jar FindBugsAnnotationsTest.java