JUnit 测试用例来检查文件是否已创建 [英] JUnit test case to check if file was created

查看:28
本文介绍了JUnit 测试用例来检查文件是否已创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的程序,它将通过缓冲写入器创建 dat 文件并将一些数据写入该文件,现在请告知我可以通过哪些 junit 测试用例来检查文件是否已创建c: 驱动器,我用的是junit 3,请指教.

I have created a simple program that wil create the dat file through buffered writer and will write some data into that file , now please advise what junit test cases I can have through which I can check whether the file is created or not in c: drive , I am using junit 3 , please advise.

推荐答案

File file = new File("c:/pathOfTheCreatedFile");
assertTrue(file.exists());
// TODO: read the file. Check that it contains what it's supposed to contain

这篇关于JUnit 测试用例来检查文件是否已创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆