Skip to content

Commit

Permalink
updated current _sometimes_ working state
Browse files Browse the repository at this point in the history
  • Loading branch information
cirquit authored and janschaefer committed Jan 20, 2017
1 parent 8dceea8 commit 8692c4c
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 67 deletions.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Sun Dec 25 13:22:58 CET 2016
#Wed Jan 11 17:38:17 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-bin.zip
20 changes: 11 additions & 9 deletions gradlew
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
Expand Down Expand Up @@ -154,16 +154,18 @@ if $cygwin ; then
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
# Escape application args
for s in "${@}" ; do
s=\"$s\"
APP_ARGS=$APP_ARGS" "$s
done

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- "$DEFAULT_JVM_OPTS" "$JAVA_OPTS" "$GRADLE_OPTS" "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"
@@ -1,12 +1,12 @@
package com.tngtech.jgiven.examples.description;

import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.jgiven.Stage;
import com.tngtech.jgiven.annotation.Description;
import com.tngtech.jgiven.annotation.ExtendedDescription;
import com.tngtech.jgiven.junit.SimpleScenarioTest;
import com.tngtech.jgiven.tags.Issue;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import junitparams.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -31,7 +31,7 @@ public void steps_can_have_multiple_arguments_referenced_in_extended_description
}

@Test
@Parameters ({
@DataProvider({
"false, 0",
"true, 1"
})
Expand All @@ -41,7 +41,7 @@ public void scenarios_with_multiple_argument_parameters_can_be_shown_via_click_o
}

@Test
@Parameters({
@DataProvider({
"false, 0"
})
public void steps_can_reference_arguments_by_name_in_extended_descriptions( boolean bool, int i ) {
Expand Down
1 change: 1 addition & 0 deletions jgiven-html-app/src/js/controller/reportCtrl.js
Expand Up @@ -684,6 +684,7 @@ jgivenReportApp.controller('JGivenReportCtrl', function ($scope, $rootScope, $do
};

$scope.replaceStepExtendedDescription = function replaceStepExtendedDescription (step) {
if (step.extendedDescription === undefined) { return ""; }
var enumArray = [];
var nameArray = [];

Expand Down
29 changes: 15 additions & 14 deletions jgiven-html-app/src/js/service/tagService.js
Expand Up @@ -2,6 +2,7 @@
* Responsible for handling tag-related operations
*/
import { getTagKey, tagToString, getTagId, getTagName, undefinedOrEmpty, getScenarioId } from '../util.js'
import { forEach, sortBy, filter, values } from "lodash";

export default function TagService (dataService) {

Expand Down Expand Up @@ -35,12 +36,12 @@ export default function TagService (dataService) {
*/
function getTagScenarioMap (scenarios) {
var tagScenarioMap = {};
_.forEach(scenarios, function (testCase) {
_.forEach(testCase.scenarios, function (scenario) {
forEach(scenarios, function (testCase) {
forEach(testCase.scenarios, function (scenario) {

scenario.tags = [];

_.forEach(scenario.tagIds, function (tagId) {
forEach(scenario.tagIds, function (tagId) {

var tag = addEntry(tagId).tag;
scenario.tags.push(tag);
Expand All @@ -61,7 +62,7 @@ export default function TagService (dataService) {
tagEntry.scenarios.push(scenario);
}

_.forEach(tagEntry.tag.tags, function (tagId) {
forEach(tagEntry.tag.tags, function (tagId) {
addEntry(tagId);
});

Expand All @@ -86,7 +87,7 @@ export default function TagService (dataService) {
* navigation and returns the list of root nodes
*/
function calculateRootTags () {
_.forEach(_.values(tagScenarioMap), function (tagEntry) {
forEach(values(tagScenarioMap), function (tagEntry) {
if (tagEntry.tag.hideInNav) return;

var tagNode = getTagNode(tagEntry);
Expand All @@ -99,22 +100,22 @@ export default function TagService (dataService) {
nameNode.addTagNode(tagNode);
});

var nameNodesWithMultipleEntries = _.filter(_.values(tagNameMap), function (nameNode) {
var nameNodesWithMultipleEntries = filter(values(tagNameMap), function (nameNode) {
return nameNode.subTags().length > 1;
});

_.forEach(nameNodesWithMultipleEntries, function (nameNode) {
_.forEach(nameNode.subTags(), function (subTag) {
forEach(nameNodesWithMultipleEntries, function (nameNode) {
forEach(nameNode.subTags(), function (subTag) {
subTag.nameNode = nameNode;
});
});

var nodesWithoutParents = _.filter(_.values(tagNodeMap), function (tagNode) {
var nodesWithoutParents = filter(values(tagNodeMap), function (tagNode) {
return undefinedOrEmpty(tagNode.tag().tags) && !tagNode.nameNode;
});


return _.sortBy(nameNodesWithMultipleEntries.concat(nodesWithoutParents),
return sortBy(nameNodesWithMultipleEntries.concat(nodesWithoutParents),
function (tagNode) {
return tagNode.nodeName();
});
Expand All @@ -128,7 +129,7 @@ export default function TagService (dataService) {
tagNode = createTagNode(tagEntry);
tagNodeMap[key] = tagNode;
if (tag.tags && tag.tags.length > 0) {
_.forEach(tag.tags, function (parentTagId) {
forEach(tag.tags, function (parentTagId) {
var parentTag = getTagByTagId(parentTagId);
var parentTagEntry = tagScenarioMap[getTagKey(parentTag)];
var parentTagNode = getTagNode(parentTagEntry);
Expand Down Expand Up @@ -175,13 +176,13 @@ export default function TagService (dataService) {
node.scenarios = function () {
var scenarioMap = {};

_.forEach(node.subTags(), function (subTag) {
_.forEach(subTag.scenarios(), function (scenario) {
forEach(node.subTags(), function (subTag) {
forEach(subTag.scenarios(), function (scenario) {
scenarioMap[getScenarioId(scenario)] = scenario;
});
});

return _.values(scenarioMap);
return values(scenarioMap);
};

return node;
Expand Down
@@ -1,32 +1,28 @@
package com.tngtech.jgiven.report.html5;

import java.io.IOException;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;

import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.jgiven.JGivenScenarioTest;
import com.tngtech.jgiven.annotation.As;
import com.tngtech.jgiven.annotation.Description;
import com.tngtech.jgiven.annotation.ProvidedScenarioState;
import com.tngtech.jgiven.annotation.ScenarioStage;
import com.tngtech.jgiven.annotation.ScenarioState;
import com.tngtech.jgiven.report.json.GivenJsonReports;
import com.tngtech.jgiven.report.model.GivenReportModels;
import com.tngtech.jgiven.report.model.StepStatus;
import com.tngtech.jgiven.tags.BrowserTest;
import com.tngtech.jgiven.tags.FeatureAttachments;
import com.tngtech.jgiven.tags.FeatureHtml5Report;
import com.tngtech.jgiven.tags.FeatureTags;
import com.tngtech.jgiven.tags.FeatureTagsWithCustomStyle;
import com.tngtech.jgiven.tags.Issue;
import com.tngtech.jgiven.tags.*;
import com.tngtech.jgiven.annotation.Pending;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@BrowserTest
@FeatureHtml5Report
Expand Down Expand Up @@ -240,4 +236,30 @@ public void newlines_are_detected_in_formatted_values_and_shown_as_multiline_tex

}

@Test
@Issue( "236" )
@Pending
public void extended_description_can_substitue_arguments() throws IOException {
String description = "This references the first argument: $"
+ "this the second one: $2"
+ "and this the third and named one: $third_arg";

Map<String, String> argumentMap = new HashMap<>();
argumentMap.put( "first_arg", "1" );
argumentMap.put( "second_arg", "2" );
argumentMap.put( "third_arg", "3" );

String expectedDescription = "This references the first argument: 1"
+ "this the second one: 2"
+ "and this the third and named one: 3";

given().a_report_model()
.and().step_$_of_scenario_$_has_extended_description_with_arguments( 1, 1, description, argumentMap );
jsonReports
.and().the_report_exist_as_JSON_file();
whenReport.when().the_HTML_Report_Generator_is_executed();
when().the_page_of_scenario_$_is_opened( 1 );
then().an_element_with_a_$_class_exists( "has-tip" )
.and().attribute_$_has_value_$( "tooltip-html-unsafe", expectedDescription );
}
}
@@ -1,20 +1,19 @@
package com.tngtech.jgiven.report.html5;

import static org.assertj.core.api.Assertions.assertThat;
import com.tngtech.jgiven.annotation.BeforeStage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.testng.reporters.Files;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.testng.reporters.Files;

import com.tngtech.jgiven.annotation.BeforeStage;
import static org.assertj.core.api.Assertions.assertThat;

public class ThenHtml5App<SELF extends ThenHtml5App<?>> extends Html5AppStage<SELF> {

Expand Down Expand Up @@ -112,4 +111,9 @@ public SELF has_content( String content ) {
assertThat( foundElement.getText() ).isEqualTo( content );
return self();
}

public SELF attribute_$_has_value_$( String attribute, String content){
assertThat( foundElement.getAttribute( attribute ) ).isEqualTo( content );
return self();
}
}
@@ -1,21 +1,17 @@
package com.tngtech.jgiven.report.model;

import static java.util.Arrays.asList;
import com.tngtech.jgiven.Stage;
import com.tngtech.jgiven.annotation.*;
import com.tngtech.jgiven.attachment.Attachment;
import com.tngtech.jgiven.attachment.MediaType;
import com.tngtech.jgiven.report.analysis.CaseArgumentAnalyser;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.tngtech.jgiven.Stage;
import com.tngtech.jgiven.annotation.AfterStage;
import com.tngtech.jgiven.annotation.ExpectedScenarioState;
import com.tngtech.jgiven.annotation.ExtendedDescription;
import com.tngtech.jgiven.annotation.ProvidedScenarioState;
import com.tngtech.jgiven.annotation.Quoted;
import com.tngtech.jgiven.annotation.Table;
import com.tngtech.jgiven.attachment.Attachment;
import com.tngtech.jgiven.attachment.MediaType;
import com.tngtech.jgiven.report.analysis.CaseArgumentAnalyser;
import static java.util.Arrays.asList;

public class GivenReportModel<SELF extends GivenReportModel<?>> extends Stage<SELF> {

Expand Down Expand Up @@ -323,4 +319,14 @@ public SELF a_step_has_a_data_table_with_following_values( @Table List<List<Stri
}
return self();
}

public SELF step_$_of_scenario_$_has_extended_description_with_arguments(int stepNr, int scenarioNr, String description, Map<String, String> argumentMap){
StepModel stepModel = getStep( stepNr, scenarioNr );
stepModel.setExtendedDescription( description );
for (Map.Entry<String, String> entry : argumentMap.entrySet()){
Word word = Word.argWord( entry.getKey(), entry.getValue(), entry.getValue() );
stepModel.addWords( word );
}
return self();
}
}
@@ -1,7 +1,5 @@
package com.tngtech.jgiven.report.model;

import java.util.List;

import com.google.common.collect.Lists;
import com.tngtech.jgiven.Stage;
import com.tngtech.jgiven.annotation.BeforeStage;
Expand All @@ -11,6 +9,9 @@
import com.tngtech.jgiven.attachment.Attachment;
import com.tngtech.jgiven.attachment.MediaType;

import java.util.List;
import java.util.Map;

public class GivenReportModels<SELF extends GivenReportModels<?>> extends Stage<SELF> {
@ExpectedScenarioState
protected ReportModel reportModel;
Expand Down Expand Up @@ -144,4 +145,9 @@ public SELF the_scenario_has_parameters( String... params ) {
givenReportModel.the_attachments_are_added_to_step_$_of_case_$(stepNr, caseNr);
return self();
}

public SELF step_$_of_scenario_$_has_extended_description_with_arguments(int stepNr, int scenarioNr, String description, Map<String, String> argumentMap){
givenReportModel.step_$_of_scenario_$_has_extended_description_with_arguments(stepNr, scenarioNr, description, argumentMap);
return self();
}
}

0 comments on commit 8692c4c

Please sign in to comment.