This is a migrated thread and some comments may be shown as answers.

Variables set to null

2 Answers 42 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
wilfredo
Top achievements
Rank 1
wilfredo asked on 17 Aug 2011, 09:53 AM
Hi,

My problem is that we have aTest.cs and a.cs.
a.cs contents a variable which will be used until the all testmethods under aTest.cs are finish, but after the first test method the variable is set to null so the remaining test methods will become failed.

Thank you.


 

2 Answers, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 17 Aug 2011, 10:25 AM
Hi Wilfredo,
    I couldn't figure out the exact setup you're using from your description.

Is the variable defined in a.cs static?
Is the variable initially not initialized (i.e. =null) ?
Do you initialize it in the first method of aTest.cs?

My guess is that the issue is related to scope. If the variable is non-static and you're creating an object of type a.cs: there's no way that you can access this object and the value for the variable in a different method. They best thing would be for you to share the code for aTest.cs and a.cs. If you choose to do that please put in some comment next to the lines of code that are related to the variable so that we may readily identify them.

Best wishes,
Stoich
the Telerik team
Vote for Telerik Test Studio at the Annual Automation Honors Voting!
0
wilfredo
Top achievements
Rank 1
answered on 17 Aug 2011, 10:28 AM
problem is solve. variable should be static and i declare it as non-static.

can this thread be deleted. because i think it's just a simple problem.

thank you
Tags
General Discussions
Asked by
wilfredo
Top achievements
Rank 1
Answers by
Stoich
Telerik team
wilfredo
Top achievements
Rank 1
Share this question
or