使用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. ...
随机推荐
- Eclipse设置UTF-8
将Eclipse所有的设置都设置为UTF-8: 1) Window -> Preferences -> General -> Workspace -> Text file en ...
- HackerRank "Median Updates"
Same as LintCode "Sliding Window Median", but requires more care on details - no trailing ...
- HackerRank "Self Balancing Tree"
Something to learn: Rotation ops in AVL tree does not require recursion. https://github.com/andreima ...
- 【Spring学习笔记-0】Spring开发所需要的核心jar包
spring开发所需要的核心jar 1. libs目录下的核心jar包: 2. common-logging-xxx.jar 来自为知笔记(Wiz) 附件列表
- php定时执行脚本
php定时执行脚本 ignore_user_abort(); // run script. in background set_time_limit(0); // run script. foreve ...
- (WPF) 文件和文件夹选择对话框。
点击button,选择一个excel文件,并将文件名显示在textbox上. private void btnSelectErrorTableFile_Click(object sender, Rou ...
- HtmlParser + HttpClient 实现爬虫
简易爬虫的实现 HttpClient 提供了便利的 HTTP 协议访问,使得我们可以很容易的得到某个网页的源码并保存在本地:HtmlParser 提供了如此简便灵巧的类库,可以从网页中便捷的提取出指向 ...
- Segment fault及LINUX core dump详解
源自:http://andyniu.iteye.com/blog/1965571 core dump的概念: A core dump is the recorded state of the work ...
- SparkSQL项目中的应用
Spark是一个通用的大规模数据快速处理引擎.可以简单理解为Spark就是一个大数据分布式处理框架.基于内存计算的Spark的计算速度要比Hadoop的MapReduce快上100倍以上,基于磁盘的计 ...
- Codeforces Round #358 (Div. 2)B. Alyona and Mex
B. Alyona and Mex time limit per test 1 second memory limit per test 256 megabytes input standard in ...