How to use two class with the same name in differe

2019-02-06 09:46发布

This question already has an answer here:

How can I access two classes with the same name in different packages?

foo.bar.myClass.class

and

foo.myClass.class

All of this in the same class

@TestRunner(Suite.class)
@SuiteTest({bar.myClass.class, myClass.class})

Thank you.

3条回答
够拽才男人
2楼-- · 2019-02-06 10:14

You need to use the fully qualified names of the classes.

 foo.bar.myClass myvar;
 foo.myClass anothervar;
查看更多
放荡不羁爱自由
3楼-- · 2019-02-06 10:15

you will have to import one and other you will be writting fully qualified path

for example in your code:

import foo.bar.myClass;

.
.
.
myClass ob; // this  will refer to foo.bar.myClass 
foo.myClass ob1 ;//this  will refer to foo.myClass
查看更多
贪生不怕死
4楼-- · 2019-02-06 10:23

Without imports:

@TestRunner(Suite.class)
@SuiteTest({foo.bar.myClass.class, foo.myClass.class})
查看更多
登录 后发表回答