日历添加天不起作用

时间:2016-12-09 16:38:41

标签: java calendar cucumber

我有一种方法可以在日历日期中放置随机天数以检查黄瓜中的某些测试... 这是错误的输出......

>  Background:                                                     #
> Accounts_accrue_interest.feature:8
>     Given Jim is a customer                                       # StepDefs.is_a_customer(String)
>     And Jim opens a savings account with account number 234       # StepDefs.opens_a_savings_account_with_account_number(String,long)
>     And the interest rate for a savings account is 2.25% per week # StepDefs.the_interest_rate_for_a_savings_account_it_per_week(String)
> diffL Fri Dec 16 16:32:46 GMT 2016 diffL Fri Dec 09 16:32:46 GMT 2016
> diffL -6
> 
>   Scenario: Account gets interest for one week  #
> Accounts_accrue_interest.feature:13
>     Given ú100.00 is deposited into account 234 # StepDefs.is_deposited_into_account(String,long)
>     When 7 days pass                            # StepDefs.days_pass(int)
>     Then 234 has a balance of ú102.25           # StepDefs.has_a_balance_of(long,String)
>       java.lang.AssertionError: expected:<102.25> but was:<100.0>
>         at org.junit.Assert.fail(Assert.java:88)
>         at org.junit.Assert.failNotEquals(Assert.java:834)
>         at org.junit.Assert.assertEquals(Assert.java:553)
>         at org.junit.Assert.assertEquals(Assert.java:683)
>         at my.bank.StepDefs.has_a_balance_of(StepDefs.java:118)
>         at ?.Then 234 has a balance of ú102.25(Accounts_accrue_interest.feature:16)
> 
> 
>   Background:                                                     #
> Accounts_accrue_interest.feature:8
>     Given Jim is a customer                                       # StepDefs.is_a_customer(String)
>     And Jim opens a savings account with account number 234       # StepDefs.opens_a_savings_account_with_account_number(String,long)
>     And the interest rate for a savings account is 2.25% per week # StepDefs.the_interest_rate_for_a_savings_account_it_per_week(String)
> diffL Thu Dec 15 16:32:46 GMT 2016 diffL Fri Dec 09 16:32:46 GMT 2016
> diffL -6
> 
>   Scenario: Account gets no interest for less than a week #
> Accounts_accrue_interest.feature:18
>     Given ú100.00 is deposited into account 234           # StepDefs.is_deposited_into_account(String,long)
>     When 6 days pass                                      # StepDefs.days_pass(int)
>     Then 234 has a balance of ú100.00                     # StepDefs.has_a_balance_of(long,String) @could

这就是我正在做的事情......

calendar.add(Calendar.DATE, arg1);

和日历是

Calendar.getInstance();

现在,如果您注意到命令行中的输出显示两个时间的相同日期(diifL),则它是运行两个时间的saem精确方法,除了一次使用参数7和第二次使用6时 但它总是给出差异6

这是差异代码..

  long diffDays = (account.getLastInterestDate().getTime()
.getTime() - curDate.getTime().getTime())
                / (1000 * 60 * 60 * 24);

请帮助

0 个答案:

没有答案