java - Robot Framework Adding Keywords -
i having issue picking custom keywords java using annotation library. issue i'm facing getting following error when executing jybot:
imported library 'org.robotframework.javalib.library.classpathlibrary' contains no keywords
imported library 'org.robotframework.javalib.library.annotationlibrary' contains no keywords
no keyword name 'create empty stack' found jybot command used: jybot example.txt.below actual test case , libraries called test case:
*** settings *** library org.robotframework.javalib.library.classpathlibrary org/robotframework/example/keyword/**.class library org.robotframework.javalib.library.annotationlibrary org/robotframework/example/keyword/**.class *** test cases *** stack example create empty stack add element java add element c++ remove last element last element should
below library written incorporate keyword written incorporate stack keywords:
package org.robotframework.example.keyword; import org.robotframework.javalib.annotation.robotkeyword; import org.robotframework.javalib.annotation.robotkeywords; import org.robotframework.javalib.library.annotationlibrary; /** * */ /** * */ @robotkeywords public class stackkeyword extends annotationlibrary { /** means same instance of class used throughout * lifecycle of robot framework test execution. */ public static final string robot_library_scope = "global"; public stackkeyword() { super("org/robotframework/example/keyword/**/*.class"); } //</editor-fold> /** functionality tested */ private java.util.stack<string> teststack; /** * keyword-method create empty stack. */ @robotkeyword public void createanemptystack() { teststack = new java.util.stack<string>(); } /** * keyword-method add element stack. * @param element element */ @robotkeyword public void addanelement(string element) { teststack.push(element); } /** * keyword-method remove last element stack. */ @robotkeyword public void removelastelement() { teststack.pop(); } /** * keyword-method search element position. * @param element element * @param pos expected position */ @robotkeyword public void elementshouldbeatposition(string element, int pos) throws exception { if (teststack.search(element) != pos) { throw new exception("wrong position: " + teststack.search(element)); } } /** * keyword-method check last element in stack. * @param result expected resulting element */ @robotkeyword public void thelastelementshouldbe(string result) throws exception { string element = teststack.pop(); if (!result.equals(element)) { throw new exception("wrong element: " + element); } } }
add class extends annotationlibrary
, implement default constructor.
public class demolibrary extends annotationlibrary { public demolibrary () { super("org/robotframework/example/**/*.class"); } }
put keywords class under package org.robotframework.example.keywords
in example.txt file put only;
library org.robotframework.example.demolibrary
be sure have demolibrary @ path.
Comments
Post a Comment