Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Loggins for empty or non existing feature dir is added. Exeptions wil… #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions src/it/junit/issue_147-featuresDirEmpty/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.temyers.it</groupId>
<artifactId>issue_147</artifactId>
<version>1.0-SNAPSHOT</version>

<description>An IT verifying the behavior when feature dir doesn't exist or is empty</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>1.2.2</cucumber.version>
</properties>

<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<glue>
<package>foo</package>
<package>bar</package>
</glue>
</configuration>
</execution>
</executions>
<configuration>
<featuresDirectory>src/test/resources/features/emptyDir</featuresDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Scenario: Features directory is empty
Given the features directory is empty
When I perform a build
Then a warning log message should be created
But the build should succeed
And no runners should be generated
10 changes: 10 additions & 0 deletions src/it/junit/issue_147-featuresDirEmpty/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def logFile = new File(basedir, 'build.log')
content = logFile.text

assert content.contains('Features directory is empty. No runners will be generated')


def directory = new File(basedir, "target/generated-test-sources/cucumber")

assert directory.isDirectory()
assert directory.listFiles().length==0
1 change: 0 additions & 1 deletion src/it/junit/no-features-dir/invoker.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,20 @@ public class GenerateRunnersMojo extends AbstractMojo implements FileGeneratorCo
public void execute() throws MojoExecutionException {

if (!featuresDirectory.exists()) {
throw new MojoExecutionException("Features directory does not exist");
getLog().warn("Features directory does not exist");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resources plugin just informs us about skipping the non existing resources but does include the missing directory name. The first keeps the messages standardized, the latter is helpful.

[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ simmetrics-example ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/mpkorstanje/Projects/SimMetrics/simmetrics/simmetrics-example/src/test/resources

So I think this should be skip non existing featuresDirectory /home/user/path/to/features

return;
}

createOutputDirIfRequired();

final Collection<File> featureFiles = listFiles(featuresDirectory, new String[] {"feature"}, true);
final List<File> sortedFeatureFiles = new NameFileComparator().sort(new ArrayList<File>(featureFiles));

createOutputDirIfRequired();
if (featureFiles.isEmpty()) {
getLog().warn("Features directory is empty. No runners will be generated.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surefire informs us that there were no tests to run.

[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ simmetrics-example ---
[INFO] No tests to run.

I think this should be No runners to generate.

It is also possible that when there are feature files, none generate runners due to a combination of tags. So I think this notification should be moved to the CucumberITGenerator implementations.

return;
}

final List<File> sortedFeatureFiles = new NameFileComparator().sort(new ArrayList<File>(featureFiles));

File packageDirectory = packageName == null
? outputDirectory
Expand Down