Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Using global variables(Using global variables)
Using global variables [message #484015] Thu, 03 September 2009 21:26 Go to next message
M. K. is currently offline M. K.Friend
Messages: 9
Registered: September 2009
Junior Member
I'm new to community forums and SWTBot. I am a QA Analyst using this tool to create test scripts for Eclipse plug-ins that communicate with a mainframe. I set a global variable to an initial at the beginning of my test, change the value, and then base actions on this value. It appears as though the adjustment is not being propagated when the exception occurs. The statements under the IF are still being executed.

public class RecallDataset {
private static SWTWorkbenchBot bot;
String migrated = "Yes";

@Test
public void DatasetRecall() throws Exception {

try {
statements
}
catch (Exception e) {
Migrated = "No";
}
} // end of DatasetRecall

@Test
public void BrowseDataset() throws Exception {

if (migrated.equals("Yes")) {
statements, etc.
}
} // end of BrowseDataset
}

How do I pass values between public methods?

Thanks,

MK
Re: Using global variables [message #484044 is a reply to message #484015] Fri, 04 September 2009 04:13 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
The problem here is that each of the tests use a different instance of
the RecallDataset class, if you'd like to share the same variable
instance across tests, you'd want to use either (a) static member
variables or (b) set the variable in a setup[1] or teardown method.

On a side note though, having tests coupled to each other is probably a
bad idea and may have weird repercussions when one of the tests failures
may cause other tests to fail. You may possibly want to look at the
junit faq[1] on how you could possibly decouple tests from the setup and
teardown.

[1] - http://junit.sourceforge.net/doc/faq/faq.htm#organize_3

--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr


On 04/09/09 2:56 AM, M. Keller wrote:
> I'm new to community forums and SWTBot. I am a QA Analyst using this
> tool to create test scripts for Eclipse plug-ins that communicate with a
> mainframe. I set a global variable to an initial at the beginning of my
> test, change the value, and then base actions on this value. It appears
> as though the adjustment is not being propagated when the exception
> occurs. The statements under the IF are still being executed.
>
> public class RecallDataset {
> private static SWTWorkbenchBot bot;
> String migrated = "Yes";
>
> @Test
> public void DatasetRecall() throws Exception {
>
> try {
> statements
> }
> catch (Exception e) {
> Migrated = "No";
> }
> } // end of DatasetRecall
>
> @Test
> public void BrowseDataset() throws Exception {
> if (migrated.equals("Yes")) {
> statements, etc.
> }
> } // end of BrowseDataset
> }
>
> How do I pass values between public methods?
>
> Thanks,
>
> MK
>
Re: Using global variables [message #485153 is a reply to message #484044] Thu, 10 September 2009 16:00 Go to previous message
M. K. is currently offline M. K.Friend
Messages: 9
Registered: September 2009
Junior Member
Thanks Ketan. I went with redefining my global variable as static and the adjusted value was picked up just fine. I don't really understand yet how to put in Setups and Teardowns.

I don't know Java nor have a client/server background so figuring out even the simplest syntax has been difficult at times. Is there any chance someone is working on a "quick reference" or Help for SWTBot? The tip pop-ups have been helpful, but when you don't even know what the command does or how/where to use it makes things tedious. I do searches on this site, but the comments rarely include implicit syntax I can study.

Michelle
Previous Topic:Blank screen while running SWTBot tests
Next Topic:SWTBotText.typeText(final String text) is not working when you lock computer
Goto Forum:
  


Current Time: Thu Dec 18 05:43:30 GMT 2014

Powered by FUDForum. Page generated in 0.01927 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software