I want to print the results of my JUnit tests in a .txt file.
Below is my code:
try { //Creates html header String breaks = "<html><center><p><h2>"+"Test Started on: "+df.format(date)+"</h2></p></center>"; //Creating two files for passing and failing a test File pass = new File("Result_Passed-"+df.format(date)+ ".HTML"); File failed = new File("Result_Failed-"+df.format(date)+ ".HTML"); OutputStream fstreamF = new FileOutputStream(failed, true); OutputStream fstream = new FileOutputStream(pass, true); PrintStream p = new PrintStream(fstream); PrintStream f= new PrintStream(fstreamF); //appending the html code to the two files p.append(breaks); f.append(breaks); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Below is my testcase example:
public void test_001_AccountWorld1() { // Open the MS CRM form to be tested. driver.get(crmServerUrl + "account"); nameOfIFRAME = "IFRAME_CapCRM"; PerformCRM_World1("address1_name", "address1_name", "address1_line1", "address1_postalcode", true); assertEquals(firstLineFromForm.toString(), ""); assertEquals(secondLineFromForm.toString(), "Donaustadtstrasse Bürohaus 1/2 . St"); assertEquals(postcodeFromForm.toString(), "1220"); }
I tried p.append() but it does not work. Help me please.
source share