How to run a test in PHPUnit+Selenium? - netbeans

I have everything installed and I am able to create and run tests in NetBeans fine by right clicking the test in the project menu and selecting "Run". The problem is that the browser windows opened for the test close immediately after the test is ran - meaning that the only reporting I have is what NetBeans provides and that's not enough. I don't think I want to use the command line, plus I haven't had much success with it in the past anyways.
Is it possible to just point the browser at the test.php file? When i try to do that I get this error:
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in C:\xampp\php\PEAR\PHPUnit\Extensions\SeleniumTestCase.php on line 275
Shouldn't i be able to execute these test from a different machine? ie PC1 is my dedicated selenium test box and I want to tell it to run test.php from PC2 remotely.
Where should my test files go?
How do I customize the reporting/out put from the test script?

You could add a sleep(60) at the end of your test :) This would prevent PHPUnit from closing the Selenium session.
Alternatively, store your selenium tests as html files compatible with the Selenium IDE Firefox extension and let the test simply run in your browser.

I found out how to run my test files remotely - i just created a script that would execute phpunit from the command line:
<?php
exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output);
echo "<pre>". var_export($output,TRUE)."</pre>";
exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output);
echo "<pre>". var_export($output,TRUE)."</pre>";
?>
then I can just hit the URL of that script to have it run - works great, but I still think there should be a better/easier way...

Related

How can I pass a fail test in Selenium IDE?

I have a little problem with Selenium IDE. When I open an website and it fails because of timeout, Selenium won't run the next tests where I created a while loop so it will always refresh the webpage if it's not loaded.
My question is, how can make Selenium pass on the next command if the "open" command fails for timeout. Or please suggest any other workaround in case the page is loading continuously .
Thanks, Alex

How do you run tests from the command line?

To do this in-editor you open the automation tab, connect to the session and choose which tests to run.
How do you do it from the command line?
(NB. not compiling UnrealEngine/Engine/Build/BatchFiles/* comprehensively covers both building the application and compiling it. Specifically, given that you have code that is 100% happy to compile, how do you kick the test suite off)
--
Here's some more info, from recent testing on 4.10:
Running tests from the editor:
UE4Editor Project.uproject -ExecCmds="Automation RunTests MyTest"
Notice the absence of the -Game flag; this launches the Editor and runs the tests successfully in the editor console.
Running the game engine and using the 'popup log window':
UE4Editor Project.uproject -Game -ExecCmds="Automation RunTests MyTest" -log
This runs the game in 'play' mode, pops up an editor window; however, the logs stop at:
LogAssetRegistry: FAssetRegistry took 0.0004 seconds to start up
...and the game never closes or executes the tests.
Running the game engine and logging to a file:
UE4Editor Project.uproject -Game -ExecCmds="Automation RunTests MyTest" -log=Log.txt
This runs the game in 'play' mode, and then stops and never exists.
It does not appear to run any tests or log to any files.
The folder Saved/Logs does not exist after quitting the running game.
Running in the editor, test types, etc...
see: https://answers.unrealengine.com/questions/358821/hot-reload-does-not-re-compile-automation-tests.html,
Hot reload is not supported for tests; so this isn't an option.
There's also been some suggestion in various places that the test type (eg. ATF_Game, ATF_Editor) has some affect on if runs are or can be run; perhaps this is an issue to, but I've tried all kind of combinations with no success.
--
I've tried all kinds of combinations of things trying to get this working, with no success so it's time for a bounty.
I'll accept an answer which reliably:
Executes a specific test from the command line
Logs the output from that test to a file
Right, no one has any idea here or on the issue tracker.
After some serious digging through the UE4 source code, here's the actual deal, which I leave here for the next suffering soul who can't figure this out:
To run tests from the command line, and log the output and exit after the test run use:
UE4Editor.exe path/to/project/TestProject.uproject
-ExecCmds="Automation RunTests SourceTests"
-unattended
-nopause
-testexit="Automation Test Queue Empty"
-log=output.txt
-game
On OSX use UE4Editor.app/Contents/MacOS/UE4Editor.
Notice that the logs will, regardless of what you supply, ultimately be placed in:
WindowsNoEditor/TestProject/Saved/Logs/output.txt
or
~/Library/Logs/TestProject/output.txt
Notice that for mac this is outside of your project directory, in, for example, /Users/doug/Library/Logs/TestProject. (Who thought that was a good idea?)
(see https://wiki.unrealengine.com/Locating_Project_Logs#Game_Logs)
You can list automation tests using:
-ExecCmds="Automation List"
...and then parse the response to find tests to run; automation commands may be chained, for example:
-ExecCmds="Automation List, Automation RunAll"
Do you mean the in-editor command line or the Windows command line?
In the editor you can use the Automation command with parameters, e.g. Automation RunAll
In the Windows command line you can specify unreal command parameters with -ExecCmds. To run all tests in your project: UE4Editor.exe YOURPROJECT -Game -ExecCmds="Automation RunAll"
For anyone still wondering, there is a bug in the editor that make it so the test list is flushed before they are run when they are started from the command-line (be it at startup or after).
This means that the editor actually compiles a list of tests to run, which is then flushed by another part of the program. The editor then thinks that it has finished running all the test and, since there is no errors, shows that they all succeeded.
I can post how to do a fix to this if anyone is interested, but it introduce another minor bug.

Netbeans and grunt issue with console windows 7

I want to run a grunt.js file inside a folder that is inside a netbeans project.
Test 1:
when I check if grunt is working correct in c:\Users\someuser: grunt -v
it gets me the grunt version info.
Test 2:
when Im inside the project folder with grunt inside
c:\wamp\www\project\grunt\ (with grunt.js inside)
I run grunt or grunt -v (just for testing and I get this)
The launcher has determined that the parent process has a console and will reuse
it for its own console output.
Closing the console will result in termination of the running program.
Use '--console suppress' to suppress console output.
Use '--console new' to create a separate console window.**
What can I do to fix this?
Thank you
fixed. My mistake. Mi grunt file was Grunt.js not Gruntfile.js

Eclipse External tools cannot start Meteorite: uname: command not found, even when PATH is set

In Terminal everything is working just fine:
alex#ubuntu:~/workspace/spt$ export PATH=$PATH:/usr/lib/meteor/bin
alex#ubuntu:~/workspace/spt$ mrt
Stand back while Meteorite does its thing
Done installing smart packages
Ok, everything's ready. Here comes Meteor!
[[[[[ ~/workspace/spt ]]]]]
Running on: http://localhost:3000/
Now I want to see the output in Eclipse console, so I create "External Tools Configurations" and have:
Also I add the PATH:
However when I try to run I get the following output in console:
[1m[37mStand back while Meteorite does its thing[39m[22m
[1m[37mDone installing smart packages[39m[22m
[32mOk, everything's ready. Here comes Meteor![39m
/home/alex/.meteorite/meteors/meteor/meteor/2d8b41a87cec884489ead138b5dfea31487363f3/meteor:
line 7: uname: command not found Sorry, this OS is not supported.
Any ideas on what's going on?
I think somehow when it says Append its a loose definition. If meteor can't find uname it means path has been emptied to /usr/lib/meteor/bin. You could create a complete path variable manually:
Find out your path, run echo $PATH in your terminal, and add your :/usr/lib/meteor/bin to it and use this as your path in that dialog in the screenshot.

Makegood in Eclipse says "The main script is not found"

I googled this unexpected error message and there not a single result.
I am using Eclipse Helios (3.6) with Makegood plugin to run PHPUnit test.
PHPUnit is working just fine.
I can also use Makegood to one test class.
But when I run all test, Makegood refuse to do it and display
'Launching <currentfilename>' has encountered a problem.
The main script is not found.
Looks like there are some internal issue with Makegood. I just don t know how to get started debugging this. Is this a eclipse or makegood error message? What does it mean ? Is there any log or debug mode I could use to understand what s happen ?
Recently, I've encountered this problem when executing the Run All Test command. Then the project has no PHP script under the specified test folders. Since the Xdebug implementation of PDT requires a PHP file, test cannot be run in such state.
To prevent this, MakeGood checks whether the project has at least a PHP file under the specified test folders, and skips a test run if the project has no PHP scripts. But even so this error is raised by any reason...
I created a issue http://redmine.piece-framework.com/issues/310 to fix this problem.
Thank you for using MakeGood.