1
public void createRootElement() throws FileNotFoundException, IOException
{
Properties prop = new Properties();
prop.load(new FileInputStream("/home/asdf/Desktop/test.properties"));
File file = new File(prop.getProperty("filefromroot"));
try
{
// if file doesn't exists, then create it
if (!file.exists())
{
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write("<root>"); //create the root tag for the XML File.
bw.close();
}
catch(Exception e)
{
writeLog(e.getMessage(),false);
}
}
저는 junit 테스트를 처음 사용했습니다.이 테스트 케이스를 작성하는 방법을 모두 알고 싶습니다. 메서드 호출 방법은이 테스트에서 호출됩니다.하나의 테스트에서 메소드가 호출 될 때 junit 테스트
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class ClassToBeTestedTest {
@Test
public void test() {
ClassToBeTested c = new ClassToBeTested();
c.createRootElement();
assertTrue(c.rootElementExists());
}
}
당신은 @Test 주석과 시험 방법을 표시하고 테스트 할 것을 실행하는 코드를 작성 :
시작해야합니다. http://junit.sourceforge.net/doc/faq/faq.htm – Aboutblank