[ 
http://mifosforge.jira.com/browse/MIFOS-4175?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Vivek Singh updated MIFOS-4175:
-------------------------------


Autowiring doesn't work for both scalatest as well as easyb. And yes using 
SpringContext is a workaround right now.

Groovy is a dynamic language and Scala is strongly typed functional language.
Dynamic languages provide lot more options for domain specific languages 
because of its ability to do late binding. Scala being a compiled language it 
doesn't lend itself so well to it. For writing acceptance tests easyb, based on 
groovy would be an a better option.

Groovy test
------------------
scenario "Save the cash flow", {
  given "cash flow object is defined", {
    revenue = 100.21G
    expense = 50.37G
    dateTime = new DateTime(2010, 10, 11, 12, 13, 14, 15)

    list = [new MonthlyCashFlowDetail(dateTime, revenue, expense, "my notes"),
            new MonthlyCashFlowDetail(dateTime.plusMonths(1), revenue + 20.01G, 
expense + 10.22G, "my other notes")]

    cashFlowDetail = new CashFlowDetail(list)
    cashFlowDetail.with {
      totalLiability = 123G
      totalCapital = 456G
    }
  }

  when "cash flow service and dao are available and save is called", {
    factory = ScalaUtil.getCashFlowContext()
    factory.with {
      cashFlowService = getBean("cashFlowService")
      cashFlowDao = getBean("cashFlowDao")
    }
    cashFlowId = cashFlowService.save(cashFlowDetail);
  }

  then "total capital and liability is also saved along with the cash flow", {
    cashFlow = cashFlowDao.getDetails(cashFlowId);
    cashFlow.totalLiability.shouldBe 123G
    cashFlow.totalCapital.shouldBe 456G
  }
}

Scala test
---------------
class CashFlowServiceSpec extends FeatureSpec with GivenWhenThen {

  var cashFlowService: CashFlowService = null;
  var cashFlowDao: CashFlowDao = null;

  val revenue: BigDecimal = new BigDecimal(100.21d)
  val expense: BigDecimal = new BigDecimal(50.37d)

  feature("The User should be able to save a cash flow"){
    scenario("save the cash flow") {
      given("there is a cash flow")
      val factory: BeanFactory = ScalaUtil.getCashFlowContext
      val cashFlowDetails: CashFlowDetail = getCashFlowDetails(new 
BigDecimal(123d), new BigDecimal(456d))

      when("save is called")
      cashFlowService= 
factory.getBean("cashFlowService").asInstanceOf[CashFlowService]
      cashFlowDao= factory.getBean("cashFlowDao").asInstanceOf[CashFlowDao]
      var cashFlowId: Integer = cashFlowService.save(cashFlowDetails)
      var cashFlow: CashFlow = cashFlowDao.getDetails(cashFlowId)

      then("the cash flow should be saved")
      var totalLiability: BigDecimal = cashFlow.getTotalLiability
      var totalCapital: BigDecimal = cashFlow.getTotalCapital
      assert(totalCapital.doubleValue === 123d)
      assert(totalLiability.doubleValue === 456d)
    }
  }

  def getCashFlowDetails(totalCapital: BigDecimal, totalLiability: BigDecimal): 
CashFlowDetail = {
    var dateTime: DateTime = new DateTime(2010, 10, 11, 12, 13, 14, 15)
    var list: java.util.ArrayList[MonthlyCashFlowDetail] = new 
java.util.ArrayList[MonthlyCashFlowDetail]
    list.add(new 
org.mifos.platform.cashflow.service.MonthlyCashFlowDetail(dateTime, revenue, 
expense, "my notes"))
    list.add(new 
org.mifos.platform.cashflow.service.MonthlyCashFlowDetail(dateTime.plusMonths(1),
 revenue.add(new BigDecimal(20.01)),
      expense.add(new BigDecimal(10.22)), "my other notes"))
    val cashFlowDetail: CashFlowDetail = new CashFlowDetail(list)
    cashFlowDetail.setTotalCapital(totalCapital);
    cashFlowDetail.setTotalLiability(totalLiability);
    return  cashFlowDetail;
  }
}

> Spike on using a BDD testing framework
> --------------------------------------
>
>                 Key: MIFOS-4175
>                 URL: http://mifosforge.jira.com/browse/MIFOS-4175
>             Project: mifos
>          Issue Type: Story
>          Components: Build and Testing
>    Affects Versions: Elsie F - Iteration 6
>            Reporter: jbrewster
>            Assignee: Vivek Singh
>             Fix For: Elsie F - Iteration 6
>
>
> Do a spike on using a BDD development tool to allow for more 
> BA/developer/tester/customer visibility to what automated tests we have in 
> place.  BDD tool could be used in place of current acceptance tests, or at 
> some other functional test level.  
> Related to developer email thread - http://tinyurl.com/247u3sj.
> Some possibilities to evaluate (real choices are up the the task owner) - 
> ScalaTest, EasyB, JBehave
> Acceptance Criteria:
> Showcase Prototype(s) test built that shows contrast to current test.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://mifosforge.jira.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Mifos-issues mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mifos-issues

Reply via email to