Fitnesse

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Fitnesse

FitNesse mailing list
Hi,

I am using Spring Framework for UI Testing http://www.javaranch.com/unit-testing.jsp and I am also using Fitnesse with Given, When, Then to call the methods. Problem i am facing with Fitnesse is looks like it doesn't understand @ Autowired annotation may be, because every time i am getting Null pointer exception. I am copying my code here..Please help me to understand how this can be resolved...

I have autowired Environment .

@Autowired
public Environment env;

public boolean RuleManagerSignIn(String http://www.coderanch.com/t/410859/java/java/string-stringbuffer-stringbuilder-performance url, String Testsuite) throws Exception
{
try{
String StrUser = env.getProperty("username");
String StrPassword = env.getProperty("password");
String decryptedPwd = EncryptUtils.decrypt(StrPassword);

OpenUrl(url, Testsuite);
Thread.sleep(1000);
enterUserName(StrUser);
enterPwd(decryptedPwd);
clickSignInButton();
Thread.sleep(6000);
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

java.lang.NullPointerException http://docs.oracle.com/javase/8/docs/api/java/lang/NullPointerException.html 
at com.mastercard.bdd.RuleManager.pageobjects.RuleManagerLoginPage.RuleManagerSignIn(RuleManagerLoginPage.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at fitnesse.slim.fixtureInteraction.DefaultInteraction.methodInvoke(DefaultInteraction.java:81)
at fitnesse.slim.MethodExecutor.callMethod(MethodExecutor.java:57)
at fitnesse.slim.MethodExecutor.invokeMethod(MethodExecutor.java:38)
at fitnesse.slim.MethodExecutor.findAndInvoke(MethodExecutor.java:72)
at fitnesse.slim.FixtureMethodExecutor.execute(FixtureMethodExecutor.java:20)
at fitnesse.slim.StatementExecutor.getMethodExecutionResult(StatementExecutor.java:135)
at fitnesse.slim.StatementExecutor.call(StatementExecutor.java:108)
at fitnesse.slim.instructions.CallInstruction.executeInternal(CallInstruction.java:35)
at fitnesse.slim.instructions.Instruction.execute(Instruction.java:29)
at fitnesse.slim.ListExecutor$Executive.executeStatement(ListExecutor.java:49)
at fitnesse.slim.ListExecutor$Executive.executeStatements(ListExecutor.java:43)
at fitnesse.slim.ListExecutor.execute(ListExecutor.java:85)
at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:84)
at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:77)
at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:64)
at fitnesse.slim.SlimServer.serve(SlimServer.java:49)
at fitnesse.slim.SlimService.handle(SlimService.java:154)
at fitnesse.slim.SlimService.acceptOne(SlimService.java:162)
at fitnesse.slim.SlimService.accept(SlimService.java:124)
at fitnesse.slim.SlimService.startWithFactory(SlimService.java:76)
at fitnesse.slim.SlimService.main(SlimService.java:56)

 

Reply | Threaded
Open this post in threaded view
|

Re: Fitnesse

FitNesse mailing list
I am not aware of any FitNesse plugin which would have slim fixtures participate in the Spring lifecycle.

So I’d expect Spring to not even be started when the test process is executed.
You could probably create some static Spring application context and then in the initialiser of your fixture you could pass it’s reference to Spring for autowiring.

> On 02 Aug 2016, at 16:08, [hidden email] [fitnesse] <[hidden email]> wrote:
>
>
> Hi,
>
> I am using Spring Framework for UI Testing <http://www.javaranch.com/unit-testing.jsp> and I am also using Fitnesse with Given, When, Then to call the methods. Problem i am facing with Fitnesse is looks like it doesn't understand @ Autowired annotation may be, because every time i am getting Null pointer exception. I am copying my code here..Please help me to understand how this can be resolved...
>
> I have autowired Environment .
>
> @Autowired
> public Environment env;
>
> public boolean RuleManagerSignIn(String <http://www.coderanch.com/t/410859/java/java/string-stringbuffer-stringbuilder-performance> url, String Testsuite) throws Exception
> {
> try{
> String StrUser = env.getProperty("username");
> String StrPassword = env.getProperty("password");
> String decryptedPwd = EncryptUtils.decrypt(StrPassword);
>
> OpenUrl(url, Testsuite);
> Thread.sleep(1000);
> enterUserName(StrUser);
> enterPwd(decryptedPwd);
> clickSignInButton();
> Thread.sleep(6000);
> return true;
> }
> catch(Exception e)
> {
> e.printStackTrace();
> return false;
> }
> }
>
> java.lang.NullPointerException <http://docs.oracle.com/javase/8/docs/api/java/lang/NullPointerException.html>
> at com.mastercard.bdd.RuleManager.pageobjects.RuleManagerLoginPage.RuleManagerSignIn(RuleManagerLoginPage.java:67)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at fitnesse.slim.fixtureInteraction.DefaultInteraction.methodInvoke(DefaultInteraction.java:81)
> at fitnesse.slim.MethodExecutor.callMethod(MethodExecutor.java:57)
> at fitnesse.slim.MethodExecutor.invokeMethod(MethodExecutor.java:38)
> at fitnesse.slim.MethodExecutor.findAndInvoke(MethodExecutor.java:72)
> at fitnesse.slim.FixtureMethodExecutor.execute(FixtureMethodExecutor.java:20)
> at fitnesse.slim.StatementExecutor.getMethodExecutionResult(StatementExecutor.java:135)
> at fitnesse.slim.StatementExecutor.call(StatementExecutor.java:108)
> at fitnesse.slim.instructions.CallInstruction.executeInternal(CallInstruction.java:35)
> at fitnesse.slim.instructions.Instruction.execute(Instruction.java:29)
> at fitnesse.slim.ListExecutor$Executive.executeStatement(ListExecutor.java:49)
> at fitnesse.slim.ListExecutor$Executive.executeStatements(ListExecutor.java:43)
> at fitnesse.slim.ListExecutor.execute(ListExecutor.java:85)
> at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:84)
> at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:77)
> at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:64)
> at fitnesse.slim.SlimServer.serve(SlimServer.java:49)
> at fitnesse.slim.SlimService.handle(SlimService.java:154)
> at fitnesse.slim.SlimService.acceptOne(SlimService.java:162)
> at fitnesse.slim.SlimService.accept(SlimService.java:124)
> at fitnesse.slim.SlimService.startWithFactory(SlimService.java:76)
> at fitnesse.slim.SlimService.main(SlimService.java:56)
>
>
>
>
>