I have one test case which has to give output as a JSON and write it into a .txt file .
It works well and creates a txt file in local and writes into it. But when I run the same test with CircleCI, I get java.io.FileNotFoundException
Yes @kazurayam, it was not present when test suites executed. Later i changed the code as below -
def jsonInvoice_details = new groovy.json.JsonBuilder()
jsonInvoice_details fields: org_invoice
def jsonCC_details = new groovy.json.JsonBuilder()
jsonCC_details fields: org_cc
//KeywordUtil.logInfo(jsonInvoice_details.toString())
//KeywordUtil.logInfo(jsonCC_details.toString())
String invoices_filename = "./report/BillingInfo_Invoices.txt"
String cc_filename = "./report/BillingInfo_CC.txt"
try{
File invoicesfile = new File(invoices_filename)
File ccfile = new File(cc_filename)
if (!invoicesfile.getParentFile().exists()){
invoicesfile.getParentFile().mkdirs()
}
if (!invoicesfile.exists()){
invoicesfile.createNewFile()
}
if (!ccfile.exists()){
ccfile.createNewFile()
}
FileWriter fw_invoice_details=new FileWriter(invoices_filename)
fw_invoice_details.write(jsonInvoice_details.toString())
KeywordUtil.logInfo("Invoice Details file present at ---> "+invoicesfile.getAbsolutePath())
fw_invoice_details.close()
FileWriter fw_cc_details=new FileWriter(cc_filename)
fw_cc_details.write(jsonCC_details.toString())
KeywordUtil.logInfo("Credit card Details file present at ---> "+ccfile.getAbsolutePath())
fw_cc_details.close()
}
catch(Exception e){
KeywordUtil.logInfo(e.toString())
}
So , now i get the below output, but i am not able to see the files created in the artifacts tab -
2020-10-20 09:50:54.288 DEBUG t invoice in Billing section of each org - 17: jsonInvoice_details = new groovy.json.JsonBuilder()
2020-10-20 09:50:54.291 DEBUG t invoice in Billing section of each org - 18: jsonInvoice_details.call([“fields”:org_invoice])
2020-10-20 09:50:54.292 DEBUG t invoice in Billing section of each org - 19: jsonCC_details = new groovy.json.JsonBuilder()
2020-10-20 09:50:54.292 DEBUG t invoice in Billing section of each org - 20: jsonCC_details.call([“fields”:org_cc])
2020-10-20 09:50:54.292 DEBUG t invoice in Billing section of each org - 21: invoices_filename = “./report/BillingInfo_Invoices.txt”
2020-10-20 09:50:54.292 DEBUG t invoice in Billing section of each org - 22: cc_filename = “./report/BillingInfo_CC.txt”
2020-10-20 09:50:54.292 DEBUG t invoice in Billing section of each org - 23: try
2020-10-20 09:50:54.293 DEBUG t invoice in Billing section of each org - 1: invoicesfile = new java.io.File(invoices_filename)
2020-10-20 09:50:54.293 DEBUG t invoice in Billing section of each org - 2: ccfile = new java.io.File(cc_filename)
2020-10-20 09:50:54.293 DEBUG t invoice in Billing section of each org - 3: if (!(getParentFile().exists()))
2020-10-20 09:50:54.294 DEBUG t invoice in Billing section of each org - 1: getParentFile().mkdirs()
2020-10-20 09:50:54.295 DEBUG t invoice in Billing section of each org - 4: if (!(invoicesfile.exists()))
2020-10-20 09:50:54.295 DEBUG t invoice in Billing section of each org - 1: invoicesfile.createNewFile()
2020-10-20 09:50:54.295 DEBUG t invoice in Billing section of each org - 5: if (!(ccfile.exists()))
2020-10-20 09:50:54.296 DEBUG t invoice in Billing section of each org - 1: ccfile.createNewFile()
2020-10-20 09:50:54.296 DEBUG t invoice in Billing section of each org - 6: fw_invoice_details = new java.io.FileWriter(invoices_filename)
2020-10-20 09:50:54.299 DEBUG t invoice in Billing section of each org - 7: fw_invoice_details.write(jsonInvoice_details.toString())
2020-10-20 09:50:54.304 DEBUG t invoice in Billing section of each org - 8: logInfo("Invoice Details file present at —> " + invoicesfile.getAbsolutePath())
2020-10-20 09:50:54.304 INFO com.kms.katalon.core.util.KeywordUtil - Invoice Details file present at —> /tmp/katalon_execute/project/./report/BillingInfo_Invoices.txt
2020-10-20 09:50:54.304 DEBUG t invoice in Billing section of each org - 9: fw_invoice_details.close()
2020-10-20 09:50:54.305 DEBUG t invoice in Billing section of each org - 10: fw_cc_details = new java.io.FileWriter(cc_filename)
2020-10-20 09:50:54.305 DEBUG t invoice in Billing section of each org - 11: fw_cc_details.write(jsonCC_details.toString())
2020-10-20 09:50:54.305 DEBUG t invoice in Billing section of each org - 12: logInfo("Credit card Details file present at —> " + ccfile.getAbsolutePath())
2020-10-20 09:50:54.305 INFO com.kms.katalon.core.util.KeywordUtil - Credit card Details file present at —> /tmp/katalon_execute/project/./report/BillingInfo_CC.txt
2020-10-20 09:50:54.306 DEBUG t invoice in Billing section of each org - 13: fw_cc_details.close()
2020-10-20 09:50:54.306 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/Intentwise/Billing/Check if there is a CC and past invoice in Billing section of each org
2020-10-20 09:50:54.412 INFO com.kms.katalon.core.util.KeywordUtil - Start generating HTML report folder at: /tmp/katalon_execute/project/Reports/20201020_094923/Billing/20201020_094924…
2020-10-20 09:50:54.527 INFO com.kms.katalon.core.util.KeywordUtil - HTML report generated
I am missing out something here.
Please do let me know your observations.
Thanks in advance.