Use nunit for unit testing to read configuration files

Source: Internet
Author: User
I encountered such a problem today, I wrote a test project for all the projects (mainly to facilitate testing) CodeManagement), I need to test a module, this module will read the configuration file information, I will deserialize the configuration information to a class, verify that the deserialized class matches the information in the configuration file.
Since previous unit tests did not involve testing and reading applications ProgramConfiguration File Information, So I first thought of writing the configuration information in the nunit GUI application configuration file, because nunit is the host application and other modules are called by him, so reading the configuration information is also read from its configuration file, so it is done, and then run, always red light. After debugging, I found that the configuration information was not read at all. I thought that this configuration file was not read by the tested module, so I found it online again, it is found that the module under test is the host application of the configuration file it reads, so the configuration file name should be the file name of the module under test +. config. If the tested module is ABC. DLL, the configuration file it reads should be ABC. DLL. config
The configuration file is created, run, OK, the green light is on, and the problem is solved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.