Testing product configuration files in a product-free environment

What is the best way to test production-only configuration files before they are deployed to create?

Configuration files for a non-productive environment can be easily tested in their respective environments. But how can you test the production environment before deploying production?

For example, the database name in STAGE is different from the database name in prod.

What to do if the STAGE configuration file has the correct database name and is checked in order. The prod configuration file now has a typo in the configuration file. This typo will not be detected until it is deployed in production.

Is there a way to test this configuration file with typo error before it starts working?

thank

+3
source share
4 answers

In the appSettingsweb.config file, I use this key:

<add key="CurrentEnvironment" value="0"/>
<!--        
    Public Enum Environments
       Development = 0          
       Alpha = 1                
       ReleaseCandidate = 2    
       Production = 3           
    End Enum
-->

And as you can see in my comments, this corresponds to Enum in my Helpers.vb class, which is used like this:

Public Shared CurrentEnvironment As Environments = DirectCast(WebConfigurationManager.AppSettings("CurrentEnvironment"), Environments)

This allows you to write environment-specific code such as URLs, database connections, etc.

I found it very useful.

- sorry for the VB.NET code, but I'm sure you can easily hide -

EDIT based on OP editing:

Why don't you create a Unit Test project ?

0
source

Staging, .

, .

+3

, , , ( .).

PREPROD STAGING PROD , , PROD, , , . PREPROD , PROD config .

The above two should help you. You can also see AB deployment or Blue-Green deployment

+1
source

Probably the best way to achieve this is to create a separate website in your production environment as a “stage." Then you can first flip your new configuration to this site to check it, and if everything looks fine, move it to your real production site. Otherwise, you will not be guaranteed that it will behave the same as on your production server.

0
source

All Articles