Set default folder in PhpStorm generate test - phpunit

I'm trying to speed up my workflow for generating tests, and so after assigning shortcut for generate tests, I'd like to avoid selecting the directory every single time.
We have multiple tests directories based on type of the test, but most often I create tests in /tests/unit, which is like 6th of 9 directories that PhpStorm offers. And selecting this over and over really sucks.
Also, I found out that methods are selected based on where your caret is, so that when I'm in the getComposerForDealIncomeType function, it is checked by default. When the cursor is outside of any method, the _construct is pre-selected.
So my goal is following:
set default directory
pre-select all of the functions other than the constructor
Is that possible?

Related

Making webdriverio to run test cases for multiple similar pages?

I am using webdriverio to automate certain test cases. I am using the POM style to organise my project. I am facing an issue where I want to use the same test code for n pages, and all of the pages are clones (only theme changes),is there any way I can set webdriverio to run the testcases for all of the websites and give me results individually?
If you execute the tests using TestNG, then use DataProviders aka make your tests accept parameters (like the page name you wanna test) and create a functon that wil provide these parameters. IF you annotate these functions properly, TestNG will record different resuts for each iteration. There is an extension for JUnit that provides the same for that framework as well.

Robot Framework Test Flow

It's possible to require an execution of a specific test case before the execution of the current test case?
My test cases are organized in several folder and it's possible that a test require the execution of the another test placed in the another folder (see the image below).
Any suggestions?
There is nothing you can do if the test cases are in different files, short of reorganizing your tests.
You can control the order that suites are run, and you can control the order of tests within a file, but you can't control the order of tests between files.
Best practices suggest that tests should be independent and not depend on other tests. In practice that can be difficult, but at the very least you should strive to make test suites independent of one another.
This is not a good / recommended / possible way to go.
Robot framework doesn't support it, and for a good reason. It is not sustainable to create such dependencies in the long term (or even short term).
Tests shouldn't depend on other tests. Mainly not on other tests from a different suite. What if the other suite was not run?
You can work around the issue in two ways:
You can define a file called
__init__.robot
In a directory. That suite setup and suite teardown in the file would run before anything in the underlying folders.
You can also turn the other test into a keyword so:
Test C simply calls a keyword that makes Test C run and also updates a global variable (Test_C_already_runs)
Test B would use then issue
run if '${Test_C_already_runs}'=='true' Test_C_Keyword
You would have to set a value to Test_C_already_runs before that anyway (as part of variable import, or as part of some suite_setup) to prevent variable not found error.

How to handle changes in objects' structure in automated testing?

I’m curious to know how feasible it is to get away from the dependency onto the application’s internal structure when you create an automated test case. Or you may need to rewrite the test case when a developer modifies a part of the code for a bug fix, etc.
We could write several automated test cases based on the applications internal object structure, but lets assume that the object hierarchy changes after 6 months or so, how do we approach these kind of issues?
I can't speak for other testing tools but at least in QTP's case the testing tool introduces a level of abstraction over the application so that non-functional changes in the application often (but not always) have no effect on the way the testing tool identifies the object.
For example in QTP all web elements are considered to be direct children of the document so that changes in the DOM (such as additional tables) don't change the object's description.
In TestComplete, there are a couple of ways to make sure that the changed app structure does not break you tests.
You can set up the Aliases tree of the Name Mapping feature. In this case, if the app structure is changed, you need to modify the Aliases tree appropriately and your test will stay working without requirement to modify them.
You can use the Extended Find feature of the Name Mapping in order to ignore parts of the the actual object tree and search for a needed objects on deeper levels.
This is what I was forced to do after losing all my work twice due to changes on the DOM structure:
Every single time I need to work with an object, I use the Find function with the ID of the object, searching for the object on the Page object. This way, whenever the DOM gets updated, my tests still run smoothly.
The only thing that will break my tests is if the object's ID get changed, but that's not very probable to happen.
Here you can find some examples of the helper functions I use.

Control order of script executions in test_package

Is it possible to control the order in which test_package executes testing scripts? I would like to start by executing some code that creates some objects shared by all individual tests. Therefore, this script needs to be executed first, before the actual test-blabla.R scripts.
I could try something like test-AAA.R or test-000.R, but I am not sure if the dir function used by testthat to list the scripts in a package, returns the same (alphabetical?) order of files on all platforms.
?test_dir says
Test files start with ‘test’ and are executed in alphabetical
order (but they shouldn't have dependencies). Helper files start
with ‘helper’ and loaded before any tests are run.
So, use helper files. i.e. create a file with a name that begins with "helper" and put in it the code that you need to run before running all the tests.

Comparing views in ClearCase

I have two dynamic views in ClearCase which, as far as I know, are supposed to be "equal".
One is supposed to look at the "Main branch" and one at some other branch (let's call it A).
I did a merge from A to Main (in the Main view) and for some reason the code at the A view compiles while Main does not.
Is there a way to compare the views for differences?
The simplest way is to use an external diff tool on those two views (like WinMerge or BeyondCompare on Windows, KDiff3 on Unix or Windows, ...).
I would actually create two new views (with the same config spec than the two initial views), to remove any "cache" effect, and start the comparison there.
Once that initial examen is done, I would start the compilation in those two views, and see if one of them still don't compile.
Don't forget that merging A to Main will not always result in the same set of files after the Merge.
It would be the same only if no evolution has taken place in Main since A started (or since the last merge from A to Main).
The setcs -current you mention will:
–cur/rent
causes the view_server to flush its caches and reevaluate the current config spec, which is stored in file config_spec in the view storage directory. This includes:
Evaluating time rules with nonabsolute specifications (for example, now, Tuesday)
Reevaluating –config rules, possibly selecting different derived objects than previously
Re-reading files named in include rules
If you depend within your config spec on an "include file" which was at the wrong version, the first setcs would set it at the right version, and the second one would read its content and set the right version for the rest.

Resources