Interface Automation increased isolation environment

1. pom file settings: 

Increase in the build node:

< Resources > 
      < Resource > 
        <-! Specify the directory where the configuration file, $ {deploy.type} is a variable parameter, which determines the environmental load profile by variable -> 
        < Directory > src / main / Resources . deploy.type $ {} </ Directory > 
        <-! exclude .jsp file, the file is not loaded .jsp -> 
        < excludes > 
          < the exclude > * .jsp </ the exclude > 
        </ excludes > 
      </ Resource > 
      < Resource > 
        < Directory > the src / main / Resources </directory>
      </resource>
    </resources>

Insert the new node:

< Profiles > 
    <-! Test Environment -> 
    < Profile > 
      < the above mentioned id > UAT </ the above mentioned id > 
      < Activation > 
        <-! Said that if the environment is not specified at compile time, places the environment is the default setting -> 
        < activeByDefault > to true </ activeByDefault > 
      </ Activation > 
      < Properties > 
        < deploy.type > UAT </ deploy.type > 
      </ Properties > 
    </ Profile >

    <!-- 生产环境 -->
    <profile>
      <id>prod</id>
      <properties>
        <deploy.type>prod</deploy.type>
      </properties>
    </profile>
  </profiles>

2. Data source: two new folders in the main directory

 

In two folders, create a file named each of datasource.properties

 

 3. The method util data reading properties

private static Properties properties;

/*
     * Data taken from the datasource
     */
    public String getValue(String key) throws IOException {
        String propertiesFileName = "datasource.properties";
        InputStream stream = this.getClass().getClassLoader().getResourceAsStream(propertiesFileName);
        properties = new Properties();
        properties.load(stream);
        String value = properties.getProperty(key);
        return value;
    }

 

Guess you like

Origin www.cnblogs.com/zqlmmd/p/12074623.html