Is it possible to disconnect the internet before running a test in AppVeyor build?

I have a test scenario to test an application when there is no internet connection.

Is it possible to disable the internet connection when running the test in Appveyor?

I have tried to add the following Powershell commands. However, it doesn't work. It's stuck in the first command.

  • ps: Get-NetAdapter | format-table
  • ps: Disable-NetAdapter -Name "Ethernet 4" -Confirm:$false

Note: image: Visual Studio 2019

  1. Actually, you can perform the tests with VM disconnected from internet. The only trick here you should reboot VM after tests, so build agent could reconnect on boot:

    - ps: Get-NetAdapter | format-table
    - ps: Disable-NetAdapter -Name "Ethernet 4" -Confirm:$false
    - <your tests go here>
    - ps: Start-Sleep -s 5; Restart-Computer
    - ps: Start-Sleep -s 5
    - ps: <output or upload results>
    

    You will be able to print/push test results after reboot.

    Hope that helps.

    PS: Don't forget to enable adapter before reboot.

  2. Thanks Feodor for the suggestion. I will give it a try.

Reply to this discussion Internal reply only staff will see it

Markdown

Attaching KB article:

» »

Read more…

Attach files

Up to 10MB each.

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions