Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for robotframework-java - Robot Framework Maven Plugins #43

Closed
nottyo opened this issue Oct 4, 2016 · 10 comments
Closed

Support for robotframework-java - Robot Framework Maven Plugins #43

nottyo opened this issue Oct 4, 2016 · 10 comments

Comments

@nottyo
Copy link

nottyo commented Oct 4, 2016

Can I use this plugin with robotframework java?

@adam-wypych
Copy link
Contributor

adam-wypych commented Oct 4, 2016

Do You mean with Jython as interpreter? Can You elaborate it a little bit?

@nottyo
Copy link
Author

nottyo commented Oct 4, 2016

No. I use robotframework (https://mvnrepository.com/artifact/org.robotframework/robotframework) for Java to execute tests natively on my Maven project.
I also use the test library provided by jspringbot such as Selenium, Http library. So I'm not sure that can I apply this plugin to my robotframework project on Eclipse?

@adam-wypych
Copy link
Contributor

Hi,

I am not familiar with this jspringbot, but as far as You are using Robot Framework test suites format (tsv, txt or robot) You can use RED as Your editor. For this Maven plugin You need to create some kind of the executable wrapper and add it to RED preferences as interpreter.

Whole procedure is described in comment: #20 (comment) .

So short answer for Your question is YES. Please provide feedback if it solve Your question or if You will meet any kind of problems.

@adam-wypych
Copy link
Contributor

@nottyo could You provide any feedback? Thanks in advance.

@nottyo
Copy link
Author

nottyo commented Oct 10, 2016

@adam-wypych I haven't tried your solution yet.
In my opinion, it would be good if I can import my project to Eclipse and using your plugin to reference the java classpath (including keyword completion) automatically. Then I can execute my test using Maven command e.g. mvn clean integration-test.

You can see an example project for robotframework-java with jspringbot below
https://github.com/jspringbot/sample-http

Thank you.

@adam-wypych
Copy link
Contributor

@nottyo: I've been checked possibilities to include support for Robot Framework Maven Plugin and base on it other RF base Maven plugins. After my analysis I think for now it not exist any automatically working solution, which will be coherent working API to implement as Robot Framework interpreter provider for RED. To fully understand the problem, the most important issue is to know how Maven and standalone Robot Framework (RF) works.

In RF standalone, we have named command <interpreter> -m robot.[run|libdoc] with parameters, which always has the same name and use it doesn't required to declare it specially in any file. Code dependency of course need to be provided by CLASSPATH/PYTHONPATH or just be command line, but always generally user is responsible for resolve them.

In Maven base plugins, dependency can be mostly resolved by Maven, if particular compiled package has Maven nature. But disadvantage of this solution, will be that is required to know, which plugin is used to run RF (if any) and to know what parameter is corresponding to what parameter inside Jython with RF package (because they are not mapped one-by-one). I've been checked even the optimistic scenario that somehow we will create "artificial" interpreter Maven, with possibility to define what is what in the plugin (i.e. dryrun = runMode=DryRun). I made some check if we could like in standalone interpreter put some extra values to Maven configuration and sorry is not possible (try to override libdoc.libraryOrResourceFile for JSpringBot, only generation for JSpringBot works: mvn jspringbot:libdoc@exec-10 -Dlibdoc.output=JSpringBotLibDoc.xml), so Maven base interpreter will be required from users to put to their poms extra configuration. Additionally plugins like JSpringBot seems to do not fully follow RF fully with support of parameters, because it put wrong parameter run mode and RF complains about it:

[INFO] --- jspringbot-maven-plugin:1.6:run (default) @ sample-http ---
log4j:WARN No appenders could be found for logger (org.jspringbot.spring.Applica
tionContextFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in of.
**[ ERROR ] option --runmode not recognized**

And even if it will be run as Robot Framework library it will fails because some extra spring files are required:

[INFO] --- robotframework-maven-plugin:1.4.6:libdoc (xml) @ lib.generation --- log4j:WARN No appenders could be found for logger (org.jspringbot.spring.Applica tionContextFactory). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in fo. Initializing test library 'JSpringBotGlobal' with no arguments failed: BeanDefin itionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:spring/spring-http.xml] Offending resource: class path resource [spring/jspringbot-global.xml]; nested e xception is org.springframework.beans.factory.BeanDefinitionStoreException: IOEx ception parsing XML document from class path resource [spring/spring-http.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/s pring-http.xml] cannot be opened because it does not exist
I additionally we are have other features like library regeneration in case was changed and I do not see how features like it should works in case You will change something in pom.

Therefore I think is not economical to add some extra handling to Maven base plugins, of course You can use RED as editor for RF files (as was said in attached issue #20 (comment)), but libdocs need to be provided as XML files.

Here are maven files which I used in my tries:

  1. Libdoc generation try: mvn -f pom_2.xml -Dkeywords.class=BuiltIn -Dgroup.dep=org.robotframework -Dartifact.dep=robotframework -Dversion.dep=3.0 package
    File: https://gist.github.com/adam-wypych/812be4b0d1dc49c1f66e52140fb022b3
  2. Parameter provides try (dryrun mode as default): mvn -f pom_3.xml -Dgroup.dep=org.jspringbot -Dartifact.dep=sample-http -Dversion.dep=1.6 test
    File: https://gist.github.com/adam-wypych/ddc794c719baf1d82b109e4bf36483e8

@nottyo
Copy link
Author

nottyo commented Oct 12, 2016

@adam-wypych Thank you for your comment.
Let me show you on how to configure the RF parameters in my RF maven-based project. You can add configuration part in the jspringbot-maven-plugin.
In this example, I set the default RF test log level to 'TRACE'. You just specify tag name as your parameter name and set value for that tag

   <artifactId>jspringbot-maven-plugin</artifactId>
    <configuration>
        <logLevel>TRACE</logLevel>
    </configuration>

You may override the value of RF parameter from mvn command. Setting the value of parameter as a variable

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <RF.logLevel>TRACE</RF.logLevel>
</properties>
...
<artifactId>jspringbot-maven-plugin</artifactId>
    <configuration>
        <logLevel>${RF.logLevel}</logLevel>
    </configuration>

To override the default value just passing your value from command line
mvn clean integration-test -DRF.logLevel=INFO

Anyway, I'll try to generate the libdoc and import it to RED plugin.

Here is my example. https://github.com/nottyo/jspringbot-webtesting.git

@adam-wypych
Copy link
Contributor

adam-wypych commented Oct 17, 2016

@nottyo I understand Your concept with parameters, but it as You probably know it is not meet Your criteria regarding automatically work, still user need to manually modify Maven configuration. Anyway I think better will be to only introduce argumentFile parameter (where is possible), which gives possibility to provide RF standalone like parameters, without any other extras in Maven configuration.
The worst is that even with modified by user configuration, we solve problem partially, because we still have lack of possibilities to execute python/robotframework base scripts for show user proposal regarding modules in library or even read variables from Python files (see: https://github.com/nokia/RED/tree/master/src/RobotFrameworkCore/org.robotframework.ide.core-functions/src/main/resources/org/rf/ide/core/executor/ - *.py files) for this still access to org.python.util.jython is required.

So I think better, will be just extract what is required for proper work of normal standalone Python RF (I think is classpath) and provide it to jython.exe wrapper for (org.python.util.jython).
As I see dependencies can be collected via Maven Dependency Plugin ( http://maven.apache.org/plugins/maven-dependency-plugin/ )

mvn -o -Dgroup=org.jspringbot -Dartifact=jspringbot -f dependency_pom.xml dependency:build-classpath
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building lib.generation 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:build-classpath (default-cli) @ lib.gener
ation ---
[INFO] Dependencies classpath:
C:\Users\wypych\.m2\repository\org\jspringbot\jspringbot\1.5\jspringbot-1.5.jar;
C:\Users\wypych\.m2\repository\org\springframework\spring-core\4.3.2.RELEASE\spr
ing-core-4.3.2.RELEASE.jar;C:\Users\wypych\.m2\repository\commons-logging\common
s-logging\1.2\commons-logging-1.2.jar;C:\Users\wypych\.m2\repository\org\springf
ramework\spring-context\4.3.2.RELEASE\spring-context-4.3.2.RELEASE.jar;C:\Users\
wypych\.m2\repository\org\springframework\spring-aop\4.3.2.RELEASE\spring-aop-4.
3.2.RELEASE.jar;C:\Users\wypych\.m2\repository\org\springframework\spring-beans\
4.3.2.RELEASE\spring-beans-4.3.2.RELEASE.jar;C:\Users\wypych\.m2\repository\org\
springframework\spring-expression\4.3.2.RELEASE\spring-expression-4.3.2.RELEASE.
jar;C:\Users\wypych\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.
6.jar;C:\Users\wypych\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.ja
r;C:\Users\wypych\.m2\repository\commons-collections\commons-collections\3.2.1\c
ommons-collections-3.2.1.jar;C:\Users\wypych\.m2\repository\log4j\log4j\1.2.16\l
og4j-1.2.16.jar;C:\Users\wypych\.m2\repository\org\slf4j\slf4j-api\1.6.1\slf4j-a
pi-1.6.1.jar;C:\Users\wypych\.m2\repository\org\slf4j\slf4j-log4j12\1.6.1\slf4j-
log4j12-1.6.1.jar;C:\Users\wypych\.m2\repository\org\robotframework\robotframewo
rk\3.0\robotframework-3.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.353 s
[INFO] Finished at: 2016-10-13T13:52:16+02:00
[INFO] Final Memory: 12M/155M
[INFO] ------------------------------------------------------------------------

Dependency pom: https://gist.github.com/adam-wypych/66bf45e3a1ebd7e51835198e921de0eb#file-dependency_pom-xml

As I see run: mvn dependency:build-classpath over sample-http also creates dependency classpath.

Of course this solution will be not particular join Maven and RED, but its provide possibility to generate libdocs, get variables and run RF test base on Jython interpreter with special inclusion of Maven declared classpath and will gives some automatical part related to import Maven project and maven directories list src/[main/test]/*. The only library, which I found that is not work correctly is JSpringBotGlobal, which stricly requires to execute libdoc task even add to classpath - path related to resources files gives an information that keyword documentation cann't be retreived.

@adam-wypych adam-wypych changed the title Support for robotframework-java ? Support for robotframework-java - Maven Plugins Oct 18, 2016
@adam-wypych adam-wypych changed the title Support for robotframework-java - Maven Plugins Support for robotframework-java - Robot Framework Maven Plugins Oct 18, 2016
@KrzysztofJozefowicz
Copy link
Contributor

example provided, of there are any more questions please reopen issue.

@mustaeenbasit
Copy link

No. I use robotframework (https://mvnrepository.com/artifact/org.robotframework/robotframework) for Java to execute tests natively on my Maven project.
I also use the test library provided by jspringbot such as Selenium, Http library. So I'm not sure that can I apply this plugin to my robotframework project on Eclipse?

Can you please tell me what command did you use to execute your test ??
robot -t testcase.robot or any maven command ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants