Symfony - PHPUnit list tests - symfony

I am using Symfony 2.5.4 and I am building test using PHPUnit on my Website. I was wondering if there was a way to list all the current implemented tests. I have looked in the app/console and there is no command that interact with PHPUnit. My goal is to give this list to the testers so they don't have to test was is already tested by PHPUnit. I would be ok with a way to get all the headers of the test functions or simply the name of the functions.

Symfony does not have a command that integrates with PHPUnit. To achive your goal, you can generate a code coverage report as HTML document (e.g. phpunit -c app --coverage-html=web/coverage src/) and you can show this report to your testers. You can explain there that they don't have to test functionality covered by tests.
But, in my opinion, your testers should test also the parts of application, that are covered by tests.

Related

Ability to Configure Environment Variables for Unit Tests (Specifically xUnit) in Rider

I have an xUnit project which from the IDE I run using the Unit Tests window or the run configuration All tests from Solution.
When configuring the All tests from Solution run configuration (or creating a new configuration), the name is the only configurable field and there is no way to specify environment variables. I'm using the Generic Host pattern to configure and expose my dependency injected resources. I need multi-environment support either through launchSettings or environment variables to configure the HostingEnvironment so different configurations can be tested, but there doesn't seem to be this capability in Rider. I think based on some search results I saw when searching on the problem that Visual Studio provides this capability for running xUnit / Unit Test projects.
This forum post is old but about the same / similar problem and one of the comments links to this youtrack issue which is marked fixed but then neither comments on that issue nor the comments on any of it's related "fixed" issues say how it was fixed or what the acceptable workaround is.
File | Settings | Build, Execution, Deployment | Unit Testing | Test Runner

Stuck with creating Keyword library using Java in Eclipse and using that JAR file in RIDE

I'm new to ROBOT framework and must create library keyword using java and utilize the JAR files in RIDE editor. I have followed the below steps. But still have confusions in where to start up. Please help me to achieve this.
Steps:
1) Installed Python, wxPython, pybot, RIDE, selenium2library successfully and I'm able to work with RIDE using predefined keywords.
2) For creating own java library, Installed Eclipse Mars, Java, ROBOT IDE manually using the link https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Installation
The question here is,
Anything i'm missing to install?
How to proceed further with Robot Framework coding?
Note: I'm reading many materials in parts to proceed things. But that is confusing me what are the steps to be followed. Is there any single material that i can get having the sequences of steps that need to be followed for my requirements?
The below links I referred with,
https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Usage
Maven error "Failure to transfer..."
Create a Maven project in Eclipse complains "Could not resolve archetype"
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-set-test-suite-global-variable-keywords
Let's start with the basics. RIDE is an editor for Robot Script files. Robot Script files are executed by the Robot Framework robot application. It is important to understand the difference between these two applications. One creates files and the other uses them.
Assuming for a moment here that you have some custom functionality in a Jar file that you would like to make available inside the Robot Script files test cases. If this is indeed the case then your focus should be on create Robot Test Libraries. In the documentation there are numerous java examples given for basing your own library on.
This means that you do not need Maven, unless you want to, to create your library. Also Eclipse IDE is not needed nor is RIDE. The library you create can be used by Robot Framework even when it's run from the command line. Feel free to use them for what they are good at: writing Robot Scripts efficiently and running Robot through menu options instead of command line windows.
When you are familiar with Eclipse and comfortable with it's features, then I can also recommend using the Eclipse Application RED which is a mature Eclipse add on for creating, running and debugging Robot scripts.
There are two ways of implementing a Java routine in Robot Framework and it depends a bit on how you run Robot Framework: Python or Jython. Running Python means that you need to run the Java in a separate JVM container and connect to it. The simplest way is via Command Line interaction. This may cause some security concerns. The second approach is to use the Remote Library approach. A good example of this is the Robot Framework Sikuli Library. An added bonus is that you can run Robot and your Java application on two separate machines/servers.
The Jython way has been discussed on StackOverflow before and I gladly refer to it. Please bear in mind that although the examples refer to RIDE, the Library org.company.Keywordlibrary works in all IDE's, provided robot framework is run using Jython.
In the Jython documentation it clearly explains how to setup an Eclipse based IDE with Jython. Do keep in mind that it's recommended to use the same interpreter in development and production. I.e. if you create your scripts in Jython, do run them in 'production' also using Jython. Otherwise you open yourself up to interpreter differences where functionality does not work or behaves differently then expected.
An alternative approach with Jython is the all-in-one Robot Framework Maven JAR plugin. Adding a custom Java Library in this setup is not too difficult. A nice short tutorial can be found on the blog of Valerio Bruno. If this is your preferred route for development, then you may want to read the RED howto on integrating the Robot Framework Maven jar.
Working on your custom functionality is likely going to be a independent project in Eclipse, but can be linked to an Robot project via the Class Path settings in red.xml if you use RED or the CLASS_PATH environment variable.
Done! I have installed RED and required add on using following below steps. It worked successfully with predefined keywords. Now I'm gonna create user defined keywords/libraries using the same editor. I don't know where to start up. Will it work creating just a java project? Should I need to include any additional libraries?
Steps followed to proceed with RED:
1. RED Version Conclusion: https://github.com/nokia/RED/blob/master/release.md
2. RED Installation Instructions: https://github.com/nokia/RED/blob/master/installation.md
3. ROBOT Framework prerequisites using RED: https://github.com/nokia/RED/blob/master/red_help/first_steps/download_install.html.md
4. To verify Installations in Eclipse: Help -> Installation Details to check if RED is visible on installed features list
5. Create Project and Tests using RED in Eclipse: https://github.com/nokia/RED/blob/master/red_help/first_steps/create_run.html.md
6. RED Steps: https://github.com/nokia/RED/blob/master/First_steps.md
7. Quick STart: https://github.com/nokia/RED/blob/master/red_help/user_guide/quick_start.html.md

Bundle Setup within Codeception

I tried to setup codeception for my Symfony2 project which already has 4 working bundles and their PHPUnit testcases. Now I wanted to add codeception Testcases, especially for acceptance tests, but when I "bootstrapped" codeception I found all the generated code within my main structure. Since my application is already organized in bundles I wanted to keep the concept as well for my testcases. Especially since I already have my PHPUnit testcases within my bundles. The official s2 codeception does not really cover this. So for me some questions arise:
How to setup codeception that it works within my bundles
How can I ran with one command all my existing PHPUnit testcases AND my codeception testcases?
I just set that up in a similar way.
codeception has a -c switch that will do what you need, i.e.:
vendor/bin/codecept bootstrap src/Acme/ExampleBundle
and then:
vendor/bin/codecept run -c src/Acme/ExampleBundle
I don't know about your 2nd question. At least for Unit tests, converting them to Codeception tests was trivial, especially since my tests all inhert from an abstract class, so it took maybe 10 lines of change there, mostly setup stuff.
#Tom That doesen't work because the Symfony2-Module is looking for the bootstrap.php.cache-file which is still in the root-folder of your symfony2-app! My solution for this is to create a link in your bundle to your app/ folder! than it gonna work!
In {your-root}/src/{your-app}/{your-bundle}:
ln -s ../../../app .

Configure Eclipse to run my FlexUnit tests automatically

I'd like to set up my projects in Eclipse to run FlexUnit tests everytime I save my work.
I found an example with JUnit here : http://misko.hevery.com/2009/05/07/configure-your-ide-to-run-your-tests-automatically/
How would you do it? Is it possible to run FlexUnit tests without Flash Player?
Yes, you could create a setup much like the one Misko describes using FlexUnit4. The key is creating an ANT build script that compiles your test runner and then invokes the FlexUnit ANT task on the resulting SWF.
Once you have the ANT build script setup you can jump right into step 4, as outlined in the article.
Getting the ANT build script setup correctly can be a little tricky if you're not familiar with ANT. I found the continuous integration (CI) sample project provided by the FlexUnit4 team to be a great reference. As of this writing, it's available here:
http://opensource.adobe.com/svn/opensource/flexunit/branches/4.x/FlexUnit4SampleCIProject/
Try using Flex Builder 4 beta, it has unit testing integration built in.
Are you using the FlexUnit plugin for Eclipse?
I don't know it, but it should execute FlexUnit tests.
If you want to execute something after you saved, you could use the Save Actions in Eclipse. They are inserted in org.eclipse.jdt.ui.cleanUps (according to a mailing list post).
Oh, I recently found this blog entry: FlexUnit + Ant. It seems like it covers your problem!
Good luck with that!

Can you do "builds" with PHP scripts or an interpreted language?

Correct me if I'm wrong, but a "build" is a "compile", and not every language compiles. Continuous Integration involves building components to see if they continue to work beyond unit tests, which I might be oversimplifying. But if your project involves a language that does not compile, how do you perform nightly builds or use continuous integration techniques?
Hmm... I'd define "building" as something like "preparing, packaging and deploying all artifacts of a software system". The compilation to machine code is only one of many steps in the build. Others might be checking out the latest version of the code from scm-system, getting external dependencies, setting configuration values depending on the target the software gets deployed to and running some kind of test suite to ensure you've got a "working/running build" before you actually deploy.
"Building" software can/must be done for any software, independent of your programming langugage. Intepreted languages have the "disadvantage" that syntactic or structural (meaning e.g. calling a method with wrong parameters etc.) errors normally will only be detected at runtime (if you don't have a separate step in your build which checks for such errors e.g. with PHPLint).
Thus (automated) Testcases (like Unit-Tests - see PHPUnit or SimpleTest - and Frontend-Tests - see Selenium) are all the more important for big PHP projects to ensure the good health of the code.
There's a great Build-Tool (like Ant for Java or Rake for Ruby) for PHP too: Phing
CI-Systems like Xinc or Hudson are simply used to automagically (like anytime a change is checked into scm) package your code, check it for obvious errors, run your tests (in short: run your build) and report the results back to your development team.
Create a daily tag of your current source control trunk?

Resources