1

我正在使用集成测试框架。我知道如何使用ColumnFixtureRowFixture而且ActionFixture基本上。现在我的问题是,如果我有嵌套对象,比如CustomerobjectAddress包含一些字段的对象,我该如何解析这种对象。

前任:

        package com.sample;

        import java.sql.Date;

        public class Customer {
            private String name;
            private int no;
            private Date dob;
            private Address address;

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }

            public int getNo() {
                return no;
            }

            public void setNo(int no) {
                this.no = no;
            }

            public Date getDob() {
                return dob;
            }

            public void setDob(Date dob) {
                this.dob = dob;
            }

            public Address getAddress() {
                return address;
            }

            public void setAddress(Address address) {
                this.address = address;
            }

            @Override
            public String toString() {
                return "Customer [name=" + name + ", no=" + no + ", dob=" + dob
                        + ", address=" + address + "]";
            }

        }
        package com.sample;

        public class Address {
            private int dno;
            private String street;
            private String city;

            public int getDno() {
                return dno;
            }

            public void setDno(int dno) {
                this.dno = dno;
            }

            public String getStreet() {
                return street;
            }

            public void setStreet(String street) {
                this.street = street;
            }

            public String getCity() {
                return city;
            }

            public void setCity(String city) {
                this.city = city;
            }

            @Override
            public String toString() {
                return "Address [dno=" + dno + ", street=" + street + ", city=" + city
                        + "]";
            }
        }

现在,在我的夹具中,我想检查(使用ActionFixturegetCustomer()返回客户对象的方法。现在在parse(String s, Type)where 's' 是来自输入文件的客户对象的字符串格式,我如何将其转换为Customer对象。

我的方法合适吗?

4

0 回答 0