I have a simple set of Django test cases that fail in Eclipse. Specifically if I have something like:
resp =self.client.get('/accounts/newUser/')
self.assertEqual(resp.status_code,200)
self.assertTrue('user' in resp.context)
then it would fail because resp.context is None. I have managed to get to run from eclipse using django.test.utils.setup_test_environment(), but then I have have to do something like resp.context[0][0][0]['user'] which is less than ideal.
Is there a more clever way to get python unit tests to run from Eclipse? I've seen this solution using django-nose from eclipse and my original solution above came from here.
Related
I am using kotlin multiplatform project with js/jvm subprojects.
I used to have unit tests in jvm subproject (annotated using kotlin test annotations) and I easily ran tests using rightclick + Run 'xxx' test using junit. That option is not possible once I move those tests to common module instead.
I can still run tests using command line gradle and I even managed to create working Run configuration that worked, but I am missing that simple "right click to run" on class or even specific test method for convenience.
Is there any way to achieve that in project?
Thanks!
Which Kotlin version do you use? There was a bug with test gutters in 1.2.60, but it is fixed in the very next release which is expected to be at the beginning of the next week.
It actually should work as you described, so if it's not the version with the bug, then it's better to submit it.
I've recently upgraded from Java 6 to Java 7, and changed the Grails version accordingly to 2.3.8. Everything compiles and runs fine from the command line.
But I'm finding my version of GGTS (3.5.1.RELEASE) won't run unit tests from within the editor. I get the error:
java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
I've tried completely importing the project from scratch - no joy.
The problem applies only to Grails-specific tests in GGTS, not when I run them from the command line. It happens during the Grails initialisation registerBeans() call. Which is pulled in by the #TestFor annotation (no annotation, no problem).
Looking at other error reports with the same error, I see this seems to be something to do with versions of xml-apis. I've tried putting
compile('xml-apis:xml-apis:2.0.2')
in the grails.project.dependency.resolution ... dependencies section of BuildConfig.groovy, but it has no effect.
Any suggestions what I might do instead?
Charles
My Grails guru suggested simply moving to IntelliJ - a good, if slightly costly, approach.
But to my frustration I found a different, but similar, error in that environment too. I realised that IntelliJ imports the Eclipse editor settings for the project.
So the solution turned out to be to delete all the editor-specific files for the project, and regenerate it from the Groovy/Grails sources alone.
Charles
I am developing a Django app or two using pydev as my IDE. I like it a lot :) However, I recently got really excited about Docker and am using Docker and Fig to serve my application now. My problem is that I would like to run my tests in this build environment- seems like this is kinda the point after all!
I know how to actually do it.
fig run web python3 /code/manage.py test
would run the tests. If I didn't want to use the Django runner, I could run
fig run web python3 /code/myapp/tests.py
Either way though, I cannot figure out how to issue that command from the IDE. All of the run configurations point to the configured python.exe ... does anyone know if there is a way to replace that with a fully customized command?
Well, the PyDev launch configuration is really targeted towards running Python, but there are alternatives to running it through other ways:
Create an external tool run (run > external tools > external tools configuration): You should be able to run anything you want from there... the downside is that this isn't really integrated into PyDev, so, if you have stack-traces they won't be clickable (and you won't be able to debug either).
Create a launcher script which in turn uses subprocess to launch the command you want... if you redirect things tracebacks should be clickable. The downside is that you won't be able to create a debug session either -- but you can still use the remote debugging in this case (http://pydev.org/manual_adv_remote_debugger.html)
Improve PyDev to do that better... (i.e.: get the code: http://pydev.org/developers.html and add docker support to a project through fig -- it should be something close to org.python.pydev.django which has special integration for running in django -- with some tweaks to the start command line, even starting in debug mode directly can work here)... if you decide to go that route, you can create a feature request at https://sw-brainwy.rhcloud.com/tracker/PyDev/ and ask code-related stuff and I'll help :)
Possibly you can create a custom executable which acts like Python but in reality just forwards things to other places (i.e.: to fig run) -- I haven't actually tested this, but in theory it should work (in the past there was work to support dummy 'python' runners such as that -- i.e.: for supporting http://cctbx.sourceforge.net/ -- so, it should work -- but you still have to create this launcher script for your use case to pass things to fig run). If the work is done properly, the debugger could work here too.
Currently I am experimenting with Mono, and creating a small testproject. When I tried to write some unittests I recognized that there is no default unittest framework like in VS. I decided to go with nUnit (but mbUnit, XUnit,...) would be fine too.
My problem is, that I was not able to find a testrunner that executes my tests and displays the testresults.
Is there a good tool available (currently I am using Monodevelop 2.4)? It is not a requirement tha it is integrated within monodevelop, so an external tool would be good enough.
NUnit is fine. I am using it with mono and works perfectly. For test runner you can use
nunit-console [input]
or the gui one
nunit-gui
These apps can be probably installed from your distribution repository (Ubuntu has it for sure) or manually installed using binaries from NUnit site. As you have written, you used to use built in VS tests. If you are using resharper, nunit will integrate as well, I also find it very clean.
I'd like to add that from the gui runner is winforms application and does not look (and feel ;)) too good on my OS. Nevertheless works fine.
it's fairly easy to set up Eclipse to run a django project's tests created with django-admin startprojects, we whould just point a Run command to ./manage.py, and supply the necessary arguments.
but what can I do if a project is built using buildout?
of course, bin/biuldout creates the handy bin/test-1.1 and bin/test-trunk files, but these are not integrated with eclipse
I can even run these as an external tool from Eclipse, but how can I get the nice code recognition of running manage.py test myapp?
does anyone know a solution? is there some buildout recipe that allows me to do this?
thanks for your help!
I'm assuming you use the djangorecipe recipe (http://pypi.python.org/pypi/djangorecipe)?
In that case, why can you apparently run "manage.py test myapp" and why can't you run "bin/django test myapp"? (Or "bin/test" for that matter)?
I suppose you have to configure that manage.py call somewhere, so why can't you configure bin/django in the same way? In the end, bin/django is just a python script, too. Have you tried calling it in the same way as manage.py?