I'm trying to execute a such command in the console:
./gradlew cucumber -Pthreads=80 -Ptags=#ALL_API_TESTS
in the build.gradle:
cucumber {
threads = "$threads"
glue = 'classpath:com.sixtleasing.cucumber.steps'
plugin = ['pretty']
tags = "$tags"
featurePath = 'src/main/resources/feature'
main = 'cucumber.api.cli.Main'
}
but it doesnt work :( How can I fix it?
Your original expression set threads to a String value, when it is clearly a numeric one, so you need to use something like:
int threadsNum = "$threads".toInteger()
cucumber {
threads = threadsNum
glue = 'classpath:com.sixtleasing.cucumber.steps'
plugin = ['pretty']
tags = "$tags"
featurePath = 'src/main/resources/feature'
main = 'cucumber.api.cli.Main'
}
Hope this helps.
Related
I have a problem with my parameterized tests.
#ParameterizedTest
#ArgumentsSource(CorrectMessagesArgumentProvider.class)
void shouldSendMessageForCorrectConfiguration(SmtpConfiguration configuration) {
var expectedMessageBody = fetchMessage();
var alertSender = new AlertSender(configuration);
var alertSubject = subjectFrom();
alertSender.send(expectedMessageBody, alertSubject);
var receivedMessages = greenMail.getReceivedMessages();
assertEquals(1, receivedMessages.length);
}
#ParameterizedTest
#ArgumentsSource(IncorrectMessagesArgumentProvider.class)
void shouldNotSendMessageForIncorrectConfiguration(SmtpConfiguration smtpConfiguration) {
var expectedMessageBody = fetchMessage();
var alertSender = new AlertSender(smtpConfiguration);
var alertSubject = subjectFrom();
var expectedErrorMessage = "Error sending alert";
var actualErrorMessage =
assertThrows(
SendAlertException.class, () -> alertSender.send(expectedMessageBody, alertSubject));
assertTrue(actualErrorMessage.getMessage().contains(expectedErrorMessage));
}
When I run those tests separetly, they work correctly. But when I run suite, the second test running fails, because it is using arguments from the other test.
They're somehow sharing that resource, but I have no idea how. Any ideas?
Okey, I got it - deep in the class responsible for sending emails, I was creating session object by getDefaultInstance(). It was creating singleton which was available for all JVM processes. When I used getInstance() - it work like a charm.
I'm using JIB (not super relevant) and I want to pass in variables from command line in my deployment script.
I append using -PinputTag=${DOCKER_TAG} -PbuildEnv=nonprod in my gradle command, which is cool. But when it's missing, I want that ternary to kick in.
I'm getting the error:
Could not get unknown property 'inputTag' for project ':webserver' of type org.gradle.api.Project.
def inputTag = inputTag ?: 'latest'
def buildEnv = buildEnv ?: 'nonprod'
jib {
container {
mainClass = 'com.example.hi'
}
to {
image = 'image/cool-image'
tags = ['latest', inputTag]
}
container {
creationTime = 'USE_CURRENT_TIMESTAMP'
ports = ['8080']
jvmFlags = ['-Dspring.profiles.active=' + buildEnv]
}
}
Found Solution
def inputTag = project.hasProperty('inputTag') ? project.property('inputTag') : 'latest'
def buildEnv = project.hasProperty('buildEnv') ? project.property('buildEnv') : 'nonprod'
This seems to be working, is this the best way?
How about this?
image = 'image/cool-image:' + (project.findProperty('inputTag') ?: 'latest')
Note jib.to.tags are additional tags. jib.to.image = 'image/cool-image' already implies image/cool-image:latest, so no need to duplicate latest in jib.to.tags.
I'm having trouble with the substitution using lightbend config library .
I have an application.conf file with this content:
property.a = "propA"
list =
[
{
nameProp=one,
propToReplace = ${property.a}
},
{
nameProp=two,
propToReplace = ${property.a}
}
]
some.env {
property.a = "propEnvironment"
}
At some point in the code, I'm loading the property file using Configuration.load().
My goal is to subtitute the propToReplace with the value of property.a inside some.env, but after I run it I gets replace for the value outside (property.a = "propA").
Does anybody have an idea how to solve this?
Thanks in advance
You can substitute it by using environment variables, like running your program with:
-Dproperty.a=mySubstituteValue
I'm currently working with Cucumber and Java. I would like to retrieve that path of a file from ITestResult.
I'm currently retrieving the parameters with:
Object[] test = testResult.getParameters();
However the only thing I can access would seem the be the first objects name and nothing else.
test = {Object[1]#1492}
0 = {CucumberFeatureWrapper#1493} "Links at EDM Documents View,"
cucumberFeature = {CucumberFeature#1516}
path = "test/01-automation.feature"
feature = {Feature#1518}
cucumberBackground = null
currentStepContainer = {CucumberScenario#1519}
cucumberTagStatements = {ArrayList#1520} size = 1
i18n = {I18n#1521}
currentScenarioOutline = null
I cannot see anyway of retrieving path = "test/01-automation.feature" under cucumber feature.
Have you tried something like ((CucumberFeatureWrapper)test[0]).getCucumberFeature().getPath()?
I try to add js file to output html code in vaadin7.4.13+maven project.
I know that it is possible to use vaadin://... protocol which is translated to /VAADIN/ directory.
Now I know that this isn't the only one trick it can be used there because I've seen some other protocols being used in #JavaScript annotation but I cannot recall them. Please help me with this.
vaadin://
???://
???://
...
Looking at vaadin's source code of com.vaadin.shared.ApplicationConstants I found out these:
APP_PATH = "APP";
UIDL_PATH = "UIDL";
HEARTBEAT_PATH = "HEARTBEAT";
PUSH_PATH = "PUSH";
PUBLISHED_FILE_PATH = APP_PATH + '/' + "PUBLISHED";
APP_PROTOCOL_PREFIX = "app://";
VAADIN_PROTOCOL_PREFIX = "vaadin://";
FONTICON_PROTOCOL_PREFIX = "fonticon://";
PUBLISHED_PROTOCOL_NAME = "published";
PUBLISHED_PROTOCOL_PREFIX = PUBLISHED_PROTOCOL_NAME + "://";