Reputation: 23
I currently have an object that references cells in CSV file. My problem is when I create this object I cannot reference it in other tests without creating a new one. For example
@Test(priority=14)
public void deleteClass() throws Exception{
readingFromExcel excel = new readingFromExcel();
String cell = excel.readingFromExcel("TestSheet",1,1);
CreateClass.deleteClass(cell);
}
////@Test(priority=15)
public void deleteCategory() throws Exception{
CreateCategory.deleteCategory(cell);
}
How can I create my object cell and refer to it in two tests?
Upvotes: 0
Views: 29
Reputation: 2652
Please put the following outside any method body but inside the class (instance level variable):
String cell;
And inside the method body:
cell = excel.readingFromExcel("TestSheet",1,1);
And also make sure that first deleteClass()
and then deleteCategory()
is called when you run all the tests of this class.
Upvotes: 1