GWT Junit - error='no compilation unit for that type was seen' - gwt

I'm trying to run a GWT unit test in a sample app. I ran
cmd /c /java/gwt-windows-1.6.4/webAppCreator.cmd -out gwttasks com.gwttasks.GwtTasks
Copied in junit-4.5.jar into a lib directory, and added that to the classpath.
Ran:
cmd /c /java/gwt-windows-1.6.4/junitCreator.cmd -junit lib/junit-4.5.jar -module com.gwttasks.GwtTasks -eclipse GwtTasks com.gwt
tasks.unit.GwtJunit
When I try to run any of the generated cmd file (such as GwtJunit-hosted.cmd) or any of the launch files, I get the following error. All the web pages I've seen say to add the test source to the classpath, but it's already there, so that's not the problem. Anyone else seen this?
com.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.gwttasks.unit.GwtJunit' was not found in module 'com.gwttasks.GwtTasks'; no compilation unit for that type was seen
at com.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:390)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:626)
...

The answer could be found here :
http://raibledesigns.com/rd/entry/testing_gwt_applications

In netbeans I added the src/java and test to the class path and debugging worked!!!!!
THANKS

I just want to add that I had the same problem, because I did the (very silly) mistake to not put the GWTTestCase class into the "client" directory, but into another one. No wonder it wasn't found ;)

Related

py.test "import file mismatch" despite different names (only Windows)

I am fairly new to py.test and have tried to set up a couple of simple black box tests for some legacy code. The directory structure looks somewhat like this:
X:\
conftest.py
prgm_A\
src\
test\
test_A.py
prgm_B\
src\
test\
test_B.py
When I run py.test from X:\, using py.test v. 2.6.3 in Windows 7 (or XP), py.test returns the following type of error message:
___________ ERROR collecting /prgm_A/test/test_A.py __________________
import file mismatch:
imported module 'test_A' has this __file__ attribute:
X:\prgm_A\test\test_A.py
which is not the same as the test file we want to collect:
X:\\prgm_A\test\test_A.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for
your test file modules
<and the same for B>
I have removed the __pycache__ and .pyc files, but that did not work. That extra backslash after the drive letter looks really fishy, but I am quite sure I am not to blame for that.
When I try to run the same tests in linux (despite the fact that the programs are compiled for windows), py.test v. 2.5.1 does not have the same problem.
My workaround until now has been to run the tests for each individual program from its own test directory, but after our computers were migrated to Windows 7, this stopped working.
Any ideas?
Additional Facts/Observations
I forgot to say that the tests used to work under XP, with an earlier py.test?, provided that I stepped down to X:\prgm_[AB]\test and ran py.test from there.
Superstition: Inserting one extra level in the file structure, moving everything from X:\ to X:\one_extra_level, didn't make one bit of a difference.
I have managed to reproduce the problem with this minimal example:
# conftest.py:
import pytest
def returns_xyz():
return "xyz"
#pytest.fixture(scope="session")
def provider():
"""Provides a subprogram which returns the string 'xyz'."""
return returns_xyz
# prgm_[AB]\test\test_[AB].py:
import pytest
def test_xyz(provider):
assert "xyz" == provider()
Everything you need for resolving this issue is to remove the python path file. It's a file with this extension .pyc and remove also the folder __pycache__ if it's available on your test or project.
Lamine
As explained here, you just have to add an __init__.py file in your test folder and it will do the trick.
the issue moved to https://github.com/pytest-dev/pytest/issues/702
this is not a bug, as far as i can tell the python module name is the same for both test modules
py.test complains about different files ending up with the same module name, thus breaking details
can you verify?
edit
its been verified as bug
Delete all .pyc file in your project directory
Execute Command : find . -name *.pyc -delete
It worked for me!

sbt scalatest returning '0 test class found in package '<default package>''

I pulled the 'test-patterns-scala' Typesafe Activator template. Once loaded into Intellij 13.1.5 I right-clicked on the test/scala directory and selected 'Run->All Tests' this returned the output :
0 test class found in package '
There is also a popup which says:
Tests were not found in module 'test-patterns-scala', Use module "test-patterns-scala-build" instead
This is my first stackoverflow post, I searched for similar problems and only found the unanswered link below, however I couldn't up-vote it as a first time poster and the circumstances are a little different so I thought a new question was justified. Any help much appreciated!
Link to similar post: 0 test class found in package ‘<default package>’
I had the same problem a while ago. I got a fix by running 'sbt test' from the command line for the first go (in the project directory ofcourse).
After this the IntelliJ didn't have any problem in identifying the package and ran the test.

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.

Scala project won't compile in Eclipse; "Could not find the main class."

I have installed Eclipse 3.5.2 and today's Scala plugin from /update-current (that's Scala 2.8 final.) I can compile and run Scala projects consisting of a single singleton object that implements main().
But, if a project contains more classes, I receive the "Could not find the main class" error.
I have tried searching for the solution and I discovered:
Eclipse is correctly looking for the Main$ class, not the Main class
* under Debug Configurations, my main class is correctly identified as mypackage.Main
* my plugin is up to date and recommended for my version of Eclipse
* cleaning, restarting etc. doesn't help.
The same project will compile with scalac.
Thanks for any ideas on how to solve this.
EDIT: MatthieuF suggested I should post the code.
This snippet produces an error. It's not the most idiomatic code, but I wrote it that way to test my environment. I tried it as a single file and as separate files. It DOES work with scalac.
import swing._
class HelloFrame extends Frame {
title = "First program"
contents = new Label("Hello, world!")
}
object Hello {
val frame = new HelloFrame
def main(args : Array[String]) : Unit = {
frame.visible = true
}
}
BUT, if I nest the definition of HelloFrame within Hello, it works. This snippet runs perfectly:
import swing._
object Hello {
class HelloFrame extends Frame {
title = "First program"
contents = new Label("Hello, world!")
}
val frame = new HelloFrame
def main(args : Array[String]) : Unit = {
frame.visible = true
}
}
For me, the problem was that there was a build error (see Problems tab) which was preventing compilation; oops! The reason you see the error is that the run macro proceeds despite the failed compilation step, and attempts to run class files it expects to be there; they don't exist because there was a build error preventing compilation, so it says it can't find Main (not compiled).
Problem goes away when build can complete successfully, i.e. errors are fixed.
I guess, theoretically, there may be more complicated reasons your build is not completing successfully that are not listed in Problems.
One possibility is that you are trying to launch using ctrl-F11, but from a different class.
The Scala Eclipse plugin does not obey the defaults for Java launching. In Preferences->Run/Debug->Launching, there are some options Launch Operation->Always Launch the previously selected application, etc. This currently does not work in the Scala eclipse plugin. To launch a specified main, you need to launch it from the editor for the class.
There has been a bug raised for this. http://scala-ide.assembla.com/spaces/scala-ide/tickets/1000023-scala-launch--does-not-follow-jdt-behaviour
EDIT: This is now (mostly) fixed.
For me it was Eclipse specific problem. I noticed that .class file wasn't built at all. So bin directory doesn't have compiled classes.
When I manually compiled *.scala file using *.sbt and copied it to bin directory it was working as expected.
I tried different tips and tricks and it wasn't worked until I reinstalled Scala plugin in Eclipse .
I'd solve similar problem by executig "Project->Clean.." with next automatically building.
I had the same error message with a Java application made by myself.
The problem was that I deleted (though inside Eclipse) a jar that belonged to the Java build path, without deleting it from the Java build path (project's Properties window). When I did it the class could compile and run again.
Make sure that the .class files exist, usually below the bin directory.
In particular, if you have errors in unrelated files in the same project then the compilation may fail, and no .class files will be produced.
There can be the case of projects, containing errors, added to the build path of the application which prevents the completion of successful compilation. Make sure you remove any such project from the build path before running the application.
Removing these projects solved the problem for me.
Do you have a proper build tool setup? Like sbt have you installed it?
You can check its version by $sbt --version
If it is not setup you can download from here http://www.scala-sbt.org/download.html
You might have to restart your eclipse after installation.
Just copy your XXX.scala file code. Remove the package and create a new Scala Class. Paste your XXX.scala code. (If you are using maven, do a maven clean and build.) Run configuration again. This works for me.
I have faced this issue. I have just deleted the package name, created scala class, Written the same code, Set Build to "Build Automatically". Finally, It works perfectly fine.
Check scala-ide.log
For me the issue was that there were errors on:
AppData\Local\Temp\sbt_10d322fb\xsbt\ClassName.scala:16: error: not found: value enteringPhase
enteringPhase(currentRun.flattenPhase.next) { s fullName separator }
If you are using Intellij, mark directory as source root

Flex compiler error: "please put definition in a package" for classes that ARE in a package

This is with Flexbuilder 3.2, Eclipse 3.3.2.
I am moving my development environment to a new machine. Actionscript classes that compiled in the old environment now get a compile error:
A file found in a source-path must have an externally visible definition. If a definition in the file is meant to be externally visible, please put the definition in a package.
I do declare the package in these classes - I think failure to declare the package is the usual reason for this error.
To add to the mystery, many classes in this project compile without errors.
What should I check to diagnose this?
Problem solved - I had missed out some items in the path in the environment where I was launching Eclipse.
"C:\Program Files\Adobe\Flex Builder 3 Plug-in\sdks\3.2.0"\bin
"C:\Program Files\Adobe\Flex Builder 3 Plug-in\sdks\3.2.0"\frameworks
"C:\Program Files\Adobe\Flex Builder 3 Plug-in\jre"\bin
"C:\Program Files\Adobe\Flex Builder 3 Plug-in\jre"\lib
I'm amazed anything at all worked with this much missing from my path.