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();

   }
  • *import the methods* What are you talking about. [Please add a minimal, complete, and verifiable example](https://stackoverflow.com/help/mcve) – Scary Wombat Nov 29 '17 at 05:10
  • Edited please check – Karthik Bs Nov 29 '17 at 05:23
  • So your test-classes(1,2) are in different maven modules, right? Could you please share with us some code, project structure, ...? – hradecek Nov 29 '17 at 07: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? – Karthik Bs Nov 29 '17 at 07:38

0 Answers0