Created
November 6, 2010 13:00
-
-
Save elefevre/665399 to your computer and use it in GitHub Desktop.
Sample conversion of a basic JUnit test to one using Narrative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// our existing test | |
@Test | |
public void shouldLinkToStrategySourceCodeWithLinkBackToPaperSelectedPage() throws IOException { | |
getBackTestStore().storeStrategy(QUANT, ENDED_SOLUTION_ID, ZipUtils.zip("import com.algodeal.marketrunner.strategies.*;\n @Instruments(futures=com.algodeal.marketData.instruments.Futures.CAC_40)\npublic class MyStrategy extends AbstractStrategy {}", "MyStrategy.java")); | |
beginAtAsQuant("/users/paperTradeSolution.do?solutionId=" + ENDED_SOLUTION_ID + "&paperTrading=true"); // clicks on link executing javascript | |
beginAtAsQuant("/users/backtestHistory.html"); | |
clickLinkWithText("Show only", 1); | |
assertThat(getSolutionHtml(ENDED_SOLUTION_ID)).contains("<a href=\"/users/editStrategy.html?solutionId=" + ENDED_SOLUTION_ID + "&backUrl=/users/backtestHistory.html%3Fpage=1%26filter=PAPER\">"); | |
} | |
// with Narrative | |
@Test | |
public void shouldLinkToStrategySourceCodeWithLinkBackToPaperSelectedPage() throws IOException { | |
Given.the(quant).was_able_to(postStrategy(ENDED_SOLUTION_ID)) // | |
.was_able_to(startPaperModeOnThatStrategy()) // | |
.was_able_to(visitPage("backtest history")); | |
When.the(quant).attempts_to(viewOnlyPaperTradedStrategies()); | |
Then.the(quant).expects_that(strategy(ENDED_SOLUTION_ID)).should_be(displayed()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment