0

Am using Maven, I want to import the methods which are in test class to the main class,please let me know how to do this. Actually I have done importing the class of test to main function and created an object using the class of test, but the am getting an error like can not resolve methods.

Actually am doing unit testing , I want to import the test class(1) to the other test class(2) and in test class (2) I have to write main() and inside main() am creating the object to test class(1) and calling the required methods from test class(1) using the object created. Do I have to add any dependencies in pom.xml file of test class(2)(am using maven) or any other suggestions to do this.

Test class1.java

public class testclass1{ public void a(){ statements } public void a(){ statements } } 

Testclass2.java

import testclass1; public static void main (String args[]){ testclass1 ET =new testclass1(); ET.a(); ET.b(); } 
4
  • import the methods What are you talking about. Please add a minimal, complete, and verifiable example Commented Nov 29, 2017 at 5:10
  • Edited please check Commented Nov 29, 2017 at 5:23
  • So your test-classes(1,2) are in different maven modules, right? Could you please share with us some code, project structure, ...? Commented Nov 29, 2017 at 7:24
  • Added the project structure and yes both the test classes are under different maven modules. And what I have done is created the jar file for testclass1 and trying to add that in the pom.xml file of Testclass2.java. will it work? Commented Nov 29, 2017 at 7:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.