Specflow / automated testing - making directories inaccessible

Russ Taylor

So we're using C#/Specflow, and I have a test that reads

Given The publish directory can not be accessed

The app being tested reads/writes files from a directory, firstly checking it exists and if not throws an exception. I am testing that this exception is thrown. What I need to do is make the directory inaccessible for the duration of the test.

The options as I see it are:

  • Change the directory it's accessing by overriding it's config (Windows registry) for the duration of the test.

  • Rename the directory it's accessing for the duration of the test.

  • Change the permissions on the directory for the duration of the test.

None of these seem ideal, I'd like to leave the test server alone if possible. Can anyone tell me of a better solution to this please?

Sam Holder

An option that you didn't specify is to mock out the file access behind an interface and then have the mock simulate lack of access.

This has the benefit of not needing to change anything for the test, but means that its not longer an integration tests. If you don't mock and instead change the config/folder access then this test will need to ensure it isn't run when any other tests are running as they might consequently fail due to those changes.

This question has an example of how you might do this simply, and also links this library and this library which might be able to help.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Making an object inaccessible at runtime

From Dev

SpecFlow and User Interface testing

From Dev

Automated Testing Courses Online

From Dev

Automated testing of webrtc application?

From Dev

Flex mobile automated testing

From Dev

Using TFS for automated testing

From Dev

Magento 2 automated testing

From Dev

Implementation of automated workflow testing

From Dev

Automated testing an Orchestration

From Dev

Magento 2 automated testing

From Dev

Twilio - Automated testing on VMWare

From Dev

Why does chmod 644 make directories inaccessible?

From Dev

Making Directories with Bash Script

From Dev

Making an instance method inaccessible from a subclass

From Dev

Android Espresso predicates in automated testing?

From Dev

Best practice for organizing automated testing?

From Dev

protractor 3.0.0 and cucumber automated testing

From Dev

Android Espresso predicates in automated testing?

From Dev

Automated Testing in MVC5

From Dev

Automated testing of domain classes (Not unit testing)

From Dev

Making directories in windows batch script

From Dev

Unit Testing code that creates directories

From Dev

Appium vs Espresso for automated testing framework

From Dev

`go test` file modification monitoring for automated testing

From Dev

Using Mac Hotspot for automated testing of mobile devices

From Dev

jQuery terminal, Ember, QUnit - Automated testing issue

From Dev

Automated testing with Cucumber on BrowserStack of site behind VPN

From Dev

Automated web testing using selenium help needed

From Dev

Vbscript SQL select table generator for automated testing