使用Spring的Property文件存储测试数据 - 添加测试数据
测试数据直接写在Property文件中,如下图:
application.properties是系统自动生成,我添加了两个Property文件:HomeTestData.properties和motorTestData.properties来存储不同的测试数据。数据只要遵循Key=value格式即可,就像下面这样:
接下来为添加的两个Property文件中的数据生成get和set方法:
package com.testdata; import org.springframework.boot.context.properties.ConfigurationProperties; /**
* Created by sallyzhang on 4/26/16.
*/ @ConfigurationProperties(prefix="home", locations = "classpath:homeTestData.properties")
public class HomeTestDataSettings { private String homeValue;
private String contentValue;
private String age;
private String builtYear;
private String constructionType;
private String roofType;
private String suburbStatePostcode;
private String address;
private String homeExcess;
private String contentExcess;
private String sourceOfBusiness;
private String username;
private String password; public String getHomeValue() {
return homeValue;
} public void setHomeValue(String homeValue) {
this.homeValue = homeValue;
} public String getContentValue() {
return contentValue;
} public void setContentValue(String contentValue) {
this.contentValue = contentValue;
} public String getAge() {
return age;
} public void setAge(String age) {
this.age = age;
} public String getBuiltYear() {
return builtYear;
} public void setBuiltYear(String builtYear) {
this.builtYear = builtYear;
} public String getConstructionType() {
return constructionType;
} public void setConstructionType(String constructionType) {
this.constructionType = constructionType;
} public String getRoofType() {
return roofType;
} public void setRoofType(String roofType) {
this.roofType = roofType;
} public String getSuburbStatePostcode() {
return suburbStatePostcode;
} public void setSuburbStatePostcode(String suburbStatePostcode) {
this.suburbStatePostcode = suburbStatePostcode;
} public String getAddress() {
return address;
} public void setAddress(String address) {
this.address = address;
} public String getHomeExcess() {
return homeExcess;
} public void setHomeExcess(String homeExcess) {
this.homeExcess = homeExcess;
} public String getContentExcess() {
return contentExcess;
} public void setContentExcess(String contentExcess) {
this.contentExcess = contentExcess;
} public String getSourceOfBusiness() {
return sourceOfBusiness;
} public void setSourceOfBusiness(String sourceOfBusiness) {
this.sourceOfBusiness = sourceOfBusiness;
} public String getUsername() {
return username;
} public void setUsername(String username) {
this.username = username;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
}
}
HomeTestDataSettings
然后在入口类PropertyTestDataDemo加上EnableConfigurationProperties
@SpringBootApplication
@EnableConfigurationProperties({HomeTestDataSettings.class,MotorTestDataSettings.class})
public class PropertyTestDataDemo { public static void main(String[] args) {
SpringApplication.run(PropertyTestDataDemo.class, args);
}
}
PropertyTestDataDemo
这里解释下,PropertyTestDataDemo是SpringBoot的入口类,里面的mian函数就是入口,如果实在不明白,就记住:不要删了,就可以了。
如需转载,请注明出处,这是对他人劳动成果的尊重~
使用Spring的Property文件存储测试数据 - 添加测试数据的更多相关文章
- 使用Spring的Property文件存储测试数据 - 初始化
本系列博客有一个前提:只使用Junit编写测试,不使用类似Cucumber这类BDD框架. 用Cucumber的时候,测试数据可以直接写在feature文件里,但是仅仅使用Junit(不要问我为什么只 ...
- 使用Spring的Property文件存储测试数据 - 编写测试和调用测试数据
准备好测试数据后,我们可以开始编写测试了,在测试用例中调用我们property文件中的测试数据. 我自己写了一个TestCase作为所有测试类基类,基类中定义了两个变量来代表之前建好的两个测试数据文件 ...
- Spring property文件配置方法以及如何与工程分离
1,Spring使用property文件作为配置源 工程中难免出现一些需要每次部署都需要配置的参数,如数据源连接参数等,测试环境跟实际运行环境是不一样的. 使用spring框架的话,这些参 ...
- spring 配置文件 引入外部的property文件的两种方法
spring 的配置文件 引入外部的property文件的两种方法 <!-- 引入jdbc配置文件 方法一 --> <bean id="propertyConfig ...
- 「一站式」兼容所有云厂商文件存储Spring Boot 实现
背景 在互联网发展的今天,近乎所有的云厂商都提供对象存储服务.一种海量.安全.低成本.高可靠的云存储服务,适合存放任意类型的文件.容量和处理能力弹性扩展,多种存储类型供选择,全面优化存储成本. 当我们 ...
- 如何在java web工程下建立存储property文件的文件夹,让Java程序直接读取
如何在java web工程下建立存储property文件的文件夹,让Java程序直接读取: 步骤如下:
- Spring MVC的文件上传和下载
简介: Spring MVC为文件上传提供了直接的支持,这种支持使用即插即用的MultipartResolver实现的.Spring MVC 使用Apache Commons FileUpload技术 ...
- Spring MVC 实现文件的上传和下载
前些天一位江苏经贸的学弟跟我留言问了我这样一个问题:“用什么技术来实现一般网页上文件的上传和下载?是框架还是Java中的IO流”.我回复他说:“使用Spring MVC框架可以做到这一点,因为Spri ...
- Spring简单的文件配置
Spring简单的文件配置 “计应134(实验班) 凌豪” 一.Spring文件配置 spring至关重要的一环就是装配,即配置文件的编写,接下来我按刚才实际过程中一步步简单讲解. 首先,要在web. ...
随机推荐
- 关于checkbox的attr无效的问题
jq用了10版本的,一直发现attr无效,查找良久,由同事帮忙解决该问题,感谢. 特记录下该问题. 由于 新版本attr换成了prop的问题. $("input[name='delIds'] ...
- ios外派—本公司长年提供ios程序员外派业务(北京动点软件,可签合同)
北京动点飞扬长年提供ios工程师外派业务. 我公司程序员平均技术情况如下: 1.二年以上iPhone/ipad开发经验:2.熟练使用Xcode.Objective C编码技能:3.熟悉iOS开发框架, ...
- Saltstack系列1:安装配置
安装 安装EPEL作为安装Ansible的yum源(CentOS6.4) rpm -Uvh http://ftp.linux.ncsu.edu/pub/epel/6/i386/epel-release ...
- 利用NTFS权限与虚拟目录,在IIS 6.0的默认FTP站点中做用户隔离。
默认FTP站点为不隔离用户站点,利用NTFS权限设置,达到仅能访问指定目录效果. 是否允许匿名连接 FTP站点主目录:站点范围内有没有用户需要上传,有的话,要勾选“写入”:具体用户使用NTFS还给予写 ...
- 36. Valid Sudoku
============= Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku b ...
- DISPOSE_ON_CLOSE 和 EXIT_ON_CLOSE 的区别
If you have several JFrames open and you close one that has EXIT_ON_CLOSE it will close all the JFra ...
- PLSQL_性能优化系列02_Oracle Join关联
2014-09-25 Created By BaoXinjian
- CF 500 B. New Year Permutation 并查集
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permut ...
- pythomn
等我学号数据结构,明年就去找三胖 前端,写js相关代码.了解前端架构 而非页面设计 主要使用的是脚本语言 了解http web相关技术等 知道页面调优 浏览器加载方式等
- 简单数据访问类,生成简单SQL,自动转换成java对象
import java.util.HashMap; import java.util.List; import java.util.Map; import org.slf4j.Logger; impo ...