How can I skip a laravel dusk test case [duplicate] - laravel

I am using phpunit in connection with jenkins, and I want to skip certain tests by setting the configuration in the XML file phpunit.xml
I know that I can use on the command line:
phpunit --filter testStuffThatBrokeAndIOnlyWantToRunThatOneSingleTest
how do I translate that to the XML file since the <filters> tag is only for code-coverage?
I would like to run all tests apart from testStuffThatAlwaysBreaks

The fastest and easiest way to skip tests that are either broken or you need to continue working on later is to just add the following to the top of your individual unit test:
$this->markTestSkipped('must be revisited.');

If you can deal with ignoring the whole file then
<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
<testsuites>
<testsuite name="foo">
<directory>./tests/</directory>
<exclude>./tests/path/to/excluded/test.php</exclude>
^-------------
</testsuite>
</testsuites>
</phpunit>

Sometimes it's useful to skip all tests from particular file based on custom condition(s) defined as php code. You can easily do that using setUp function in which makeTestSkipped works as well.
protected function setUp()
{
if (your_custom_condition) {
$this->markTestSkipped('all tests in this file are invactive for this server configuration!');
}
}
your_custom_condition can be passed via some static class method/property, a constant defined in phpunit bootstrap file or even a global variable.

Related

laravel phpunit how to determine which method to run

I created a UserTest class that will be used to test many user related methods and everytime a run php vendor\phpunit\phpunit\phpunit it always goes through all the methods which is not practical , i want to know if it's pĂ´ssible to run a test on a specific method .
Thank you
There are two ways to do this. To run on a specific method you can use the filter flag.
vendor/bin/phpunit --filter name_of_the_method
You can also group files together using your phpunit.xml file. Look for the tag testsuite and create a second one.
<testsuite name="API">
<directory suffix="Test.php">./tests/ApiTests</directory>
</testsuite>
Now, you can use the "testsuite" flag to run tests in that folder only.
vendor/bin/phpunit --testsuite API
Also note the "suffix" in the directory of your testsuite. This refers to what the file must end with. You can filter the files that will run the test further by adjusting your naming convention.
Just Found an answer i needed to user --filter then the name of the class then the name of the method like this
php vendor\phpunit\phpunit\phpunit --filter UserTest::testinput

Elixir TDD tests only execute when a test file is saved

I have a fresh installation of Laravel 5.1, and am trying to run automated tests using Elixir. According to documentation, I can run gulp tdd and have my tests execute automatically each time a file is saved. I have the initial ExampleTest.php which has this test:
public function testBasicExample()
{
$this->visit('/')
->see('Laravel 5');
}
This test asserts if the default welcome.blade.php file shows Laravel 5. Each time when I save the ExampleTest.php file, the automated tests do execute, and that's great. But when I change and save the welcome.blade.php file, the tests do not execute automatically.
Is this the desired behaviour or not? If not, what could be causing it?
By default elixir comes with two tasks for your test suites. One for phpunit and the other for phpspec, in your gulpfile phpUnit method is called on the mix object for phpunit test suite.
mix.phpUnit();
mix.phpSpec();
And then you need to type Gulp watchfrom terminal.

Configuring guard to monitor controller sub-directories

I'm new to ruby and I'm trying to configure guard to monitor controllers in a nested directory.
Here is the directory structure
/app
/controllers
/manage
/my_controller.rb
Here is the watch expression that should fire when the file my_controller.rb is edited
watch(%r{^app/controllers/(.+)/(.+)_(controller)\.rb$})
{ |m| [
"spec/routing/#{m[2]}_routing_spec.rb",
"spec/#{m[3]}s/#{m[1]}/#{m[2]}_#{m[3]}_spec.rb",
"spec/acceptance/#{m[2]}_spec.rb"]
}
Note that i don't have routing or acceptance tests, I'm just trying to modify the existing controller watch statement to work with the controller in a nested directory. Also, note that I was able to successfully watch the spec file for changes by adding the following line
watch(%r{^spec/.+/.+_spec\.rb$})
Any insight would be appreciated.
Well, #rainkinz had it right. There was a typo in the specfile name that I couldn't see. I used the -d switch when running guard which printed debug statements that brought the error to my attention.

fsresource - runmode config stored in crx via xml

i'm using the fsresource sling extension to access the filesystem when working on JSP, JS, CSS and so on. When just yanking the bundle into the crx and configuring it via the OSGi console, everything works as expected. But when i try to add a new runmode (configurtion), the result is unsatisfying.
config/src/main/content/jcr_root/apps/samples/config/org.apache.sling.fsprovider.internal.FsResourceProvider.factory.config.xml
Is the path of the main configuration, which i'm using on a local instance to figure out, how to achieve the desired results, but the best i could get was an unbound configuration displayed in the
system/console/configMgr
The contents of the XML file:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
provider.roots="/apps/ui-samples"
provider.file="/Volumes/samples/ui/src/main/content/jcr_root/apps/ui-samples"
provider.checkinterval="1000"/>
Apparently, the i just thought too complicated about the name of the file.
org.apache.sling.fsprovider.internal.FsResourceProvider-samples.xml
for instance does the job.

Applescript not accepting arRsync sdef commands?

I'm using the opensource GUI frontend for rsync called "arRsync". It works great, but there's no way to automate it.
What I'm trying to do is use Applescript to run a preset (which you define in the Application) using the following simple script:
tell application "arRsync" to runPreset "presetTest1"
The problem is Applescript thinks "runPreset" is a variable, not a command. I've also tried a tell/end-tell variation of the above, no dice. The 'runPreset' command is part of arRsync.sdef
You can find the arRsync project here
I've tried opening up both Info.plist files inside the app and ticking the 'Scriptable' box (or setting it to 'true' for those of you without Property List Editor) but I'm still stuck.
I'm a scripting noob when it comes to Cocoa :p help would be greatly appreciated
The arRsync binary is missing a scripting dictionary. Build from source, first making the following changes:
Edit Info.plist in the project, setting the "Scriptable" option to true.
Fix the project's script dictionary, arRsync.sdef. The code for the runPreset command has one letter too few (command codes must be two FourCCs, or eight characters, long). Add a character to runPreset's code attribute; just about any character will work. If you want, the file can be shortened and simplified by replacing the Standard and Text suites with an include. Back up the orignal file and make a new arRsync.sdef containing:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary title="arRsync Terminology"
xmlns:xi="http://www.w3.org/2003/XInclude">
<xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef"
xpointer="xpointer(/dictionary/suite)"/>
<suite name="arRsync Suite" code="arRs">
<command name="runPreset" code="runPPrst">
<cocoa name="runPreset" class="scriptController"/>
<direct-parameter type="any"/>
</command>
</suite>
</dictionary>
Alternatively, you could just replace the runPreset command element with the one from above.
Add arRsync.sdef to the "Copy Bundle Resources" phase of the arRsync target
Switch to a Release build ("Blackbeard" is the name for the debug build).
Build it.
That should produce a scriptable version of arRsync. As you've already figured out, you also might need to play with the target SDK.

Resources