Yii2 Testing: How to run module tests along with main app test? - testing

I want to run my main application Codeception tests and have it automatically go through the tests provided by 3rd party modules (assuming they come with their own Codeception configurations) installed through composer (which means they are living in the vendor/ folder).
I don't know how this can be done. Do I need to provide some kind of Codeception run parameters? Do I have to modify the bootstrap files? Does Codeception even support something like this?

Codeception can include other test suites by using include setting in codeception.yml
Documentation: http://codeception.com/docs/08-Customization
Example:
include:
- vendor/vendor1/lib1
- vendor/vendor1/lib2
- vendor/vendor2/lib3

Related

Unable to run tests through commandline [duplicate]

We have a multi module project with the following structure
module 1
module 2
module e2e
parent pom
The module e2e contains our karate features (into the src/test/java/features folder)
We couldn't figure out how to run the karate tests using the "mvn test".
It always runs 0 tests, instead there are some feature files.
We have tried running "mvn test" from the root of the project, as well as from inside the e2e module
We have other maven projects (not multi module) and it works as expected.
Does it necessary to make some configuration action to do it?
Thanks a lot.
mvn test behind the scenes just looks for JUnit tests, it is that simple. Check that your JUnit class names end with Test - and that the maven tweak for the recommended directory structure is in place: https://github.com/intuit/karate/issues/724
Otherwise unless you follow this process, it is difficult for anyone to help you: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

How to target specific Cucumber runner classes or feature files within Jenkins?

Is it possible to target specific runner classes or feature files within Jenkins?
Let's say for example I have the following files.
Runner classes:
RunnerClass1.java
RunnerClass1.java
Feature Files:
Login.feature
SignUp.feature
Is there a way to trigger specific runner classes or feature files within the Jenkins UI, I know you can use specific plugins such as: 'Parameterised / String Parameters', has anyone else found a solution to target specific tests from Jenkins?
thanks for your help
You can tag your test cases and maven will be able to run them by these tags.
For example, When I have Login cases with #Login tags and I want to run them with Maven, I am using the following terminal script :
mvn clean test -Dcucumber.options="--tags #Login"

Add unit test paths to Codeception

I have started to create unit tests for small components and added them to a Tests subdirectory within the component directory - so everything is together. No functional or acceptance tests are needed for these simple small components.
But I have not found out how to tell Codeception to run all tests in a directory - I am looking for a similar method like in the PHPUnit config file, where I can just tell PHPUnit to go through all PHP files in a directory (<directory>src/*/*/*/Tests</directory> in PHPUnit XML config).
Also, there does not seem to be a reference for possible configuration options in Codeception - so it is really hard to find more advanced configuration options such as these. Or have I missed something?
http://codeception.com/docs/08-Customization#One-Runner-for-Multiple-Applications
In your case it would be:
include:
- src/*/*/*
But you will have to create a codeception.yml and at least one test suite for each component.
Look at https://github.com/Codeception/symfony-demo/blob/2.2/codeception.yml and https://github.com/Codeception/symfony-demo/tree/2.2/src/AppBundle for an example.

Selenium Maven Project

I am new to automated testing. I am trying to set up a Maven project for my Selenium test automation work. I put all the packages pertaining to envVariables, library, settings, resultLog, errScreenshots etc under src/test/java.
I have a couple of questions here
i)I showed this framework to my developer and he asked me to move some of the packages under src/test/resources. I am not sure whether this needs to be done or whatever I have configured is correct. If I need to move the packages to resources folder, what packages should I move? Can somebody please advise me on how to configure this?
ii) what should the src/main/java folder contain? I thought it will contain the src code of my application and test folder would contain unit tests and selenium tests. But my developer says the test folder will contain only unit test that test the classes in the src/main/java. It should not contain my selenium tests. Can somebody please explain this to me?
Regards
vasu
I am not sure about the structure of your automation project. I prefer the following hierarchy in MAVEN projects
src
|-----main
| |-----java
| |-----Pages (contains application code arranged as one Class per Page)
| |-----Steps (calls the page objects and methods called in Pages)
|-----test
|------java
| |-----Test (Opens browser and calls steps to perform test - TestNG)
|------resources
|-----InputSheets
|-----Environment Variables
The results are saved in C or D drive and are time stamped to avoid getting overwritten.
The automation helper library is created as a separate Maven project and is added as a dependency to the test project. In this way the helper library is independent from the test project and can be used across all projects if need arises.
All this being said, much of the structure is a matter of choice and varies according to your project requirements.
"src/main/" is for production code or test automation framework, not for test cases. "src/test/" is for testing stuff, including selenium tests. "java" folders are for classes, "resource" folders are for configuration and test data.
I suggest creating a separate maven module for your testing stuff: test framework and test cases.
Please refer maven directory layout page for more information.
UPDATE: I have created sample maven project to show how run selenium test with selenide.

Launching PHPUnit in PHPStorm for a single instance

I've seen a lot topics about PhpStorm, but they actually got me more confused than I was before.
Basically, my file structure looks like this:
http://i.stack.imgur.com/1nFE2.png
(This is from the Yii 1.1.13 Demo App "Blog")
Now what I want to do is to have these two options:
Choose any of these files -> Right click -> Run (as PHPUnit).
bootstrap.php and phpunit.xml have to be loaded somehow, because
these specify where to load the (Yii) classes needed.
run all tests
within a directory (including subdirectories).
Could anyone point out how to edit the run configuration to achieve this? I already managed to run single tests but the configuration for them were more complicated than to just run them from command line.
Software used:
OS: Mac OS 10.7 Lion, PHPStorm 6, Yii 1.1.13 and PHPUnit 3.7.
You can set your PHPUnit configuration and bootstrap file in the project settings (PHP -> PHPUnit). Now whenever your run a single test, testcase, directory etc. PHPStorm will use your bootstrap.
If you are using Yii, your test classes probably extend from CDbTestCase or CTestCase. PHPStorm does not know that these are tests cases, therefore it doesn't run them with PHPUnit automatically as it should with other tests cases.
What you need to do is setup Yii Framework in your PHP Include Path. You can access this menu by going to External Libraries in the left column of PHPStorm where you see your files. Once you add Yii to your projects PHP Include Path you will see the test files icon changes and has a red and green play like icon.
This means that you will be able to run them and PHPStorm will use your PHPUnit configuration to do so.
For more detailed information on how to configure phpunit with phpstorm check this article:
http://trickortip.com/825/programming/php/phpunit-vagrant-vm-remote-php-interpreter-phpstorm-mac.html/