unable to run feature file in IntelliJ - Undefined scenarios - java

I tried to run feature file by right click - run at IntelliJ editor but terminal displayed follows:
this is the configuration by default. is this correct?
please help as I am not sure what should be setup manually over here..
this is partial log copied from terminal:
Undefined scenarios:
C:/Users/tester/Dropbox/My PC (LAPTOP-1UVHO2K0)/Downloads/bdd-test-automation-workshop-master2/bdd-test-automation-workshop-master/src/test/resources/features/creating_todos/adding_new_todos.feature:9 # User should be assisted when adding todo items for the first time
C:/Users/tester/Dropbox/My PC (LAPTOP-1UVHO2K0)/Downloads/bdd-test-automation-workshop-master2/bdd-test-automation-workshop-master/src/test/resources/features/creating_todos/adding_new_todos.feature:13 # Adding a single todo item
C:/Users/tester/Dropbox/My PC (LAPTOP-1UVHO2K0)/Downloads/bdd-test-automation-workshop-master2/bdd-test-automation-workshop-master/src/test/resources/features/creating_todos/adding_new_todos.feature:20 # Adding todo items to an existing list
3 Scenarios (3 undefined)
10 Steps (10 undefined)
0m1.042s
You can implement missing steps with the snippets below:
#Given("{actor}")
public void (Actor actor) {
// Write code here that turns the phrase above into concrete actions
throw new cucumber.api.PendingException();
}
#Then("{actor}")
public void (Actor actor) {
// Write code here that turns the phrase above into concrete actions
throw new cucumber.api.PendingException();
}
#When("{actor}")
public void (Actor actor) {
}
#Then("{actor}")
public void (Actor actor, io.cucumber.datatable.DataTable dataTable) {
}
#Given("{actor}")
public void (Actor actor, io.cucumber.datatable.DataTable dataTable) {
}
Process finished with exit code 0

I added glue then it works now.
todos.stepdefinitions net.serenitybdd.cucumber.actors

Related

Do not run #After("#tag") hook if assertion fails

I have the below scenario in java bdd:
A tag that will create some data: #Before which will create some data before running the test steps
Test case with steps: Scenario having tag #DeleteData
After tag which will delete data #After("#DeleteData)
**Actual: ** #After("DeleteData) runs even if my Then assertion fails
**Expected: ** Do not run #After("#DeleteData) method should delete the data in order to investigate
Any help to achieve this?
#DeleteData
Scenario:
Given User is at FB login page
When User logs in
Then Success message is displayed: Logged in successfully
Hooks.java
#Before("DeleteData)
public void before() {
// Create some data
}
#After("DeleteData)
public void after() {
// delete data
}
StepFile.java
Given("^User is at FB login page$", () -> {
// Login logic
});
When("^User logs in$", () -> {
// Login logic
});
The("^Success message is displayed: (.*)$", (String msg) -> {
assertThat(msg).isEqualTo("Logged in successfully");
});
Cucumber can inject Scenario object into your hook method. So you can just do something like this:
#After
public void doAfter(Scenario scenario){
if(scenario.getStatus() == Status.PASSED){
// Do whatever you should
}
}
So the code inside would not execute if your scenario has completed with any different status.
It's expected that the After code always run. It should be able to run no matter which steps ran or failed.
To do that, you mighr want to set a flag like hasSucceeded (class variable) in the appropriate step and read it from the the After code.

Exception caught during firing event net.minecraftforge.event.RegistryEvent$Register#6b4d0be2: java.lang.ExceptionInInitializerError: null

//import
#EventBusSubscriber
public class RegistryHandler {
#SubscribeEvent
public static void onItemRegister(RegistryEvent.Register<Item> event) {
event.getRegistry().registerAll(ItemInit.ITEMS.toArray(new Item[0]));
}
#SubscribeEvent
public static void onBlockRegister(RegistryEvent.Register<Block> event) {
event.getRegistry().registerAll((Block[]) BlockInit.BLOCKS.toArray());
}
public static void onModelRegister(ModelRegistryEvent event) {
for (Item item : ItemInit.ITEMS) {
if (item instanceof IHasModel) {
((IHasModel)item).registerModels();
}
}
for (Block block : BlockInit.BLOCKS) {
if (block instanceof IHasModel) {
((IHasModel)block).registerModels();
}
}
}
}
So, i followed Harry Talks tutorials and tried to build the mod. It doesn't work for some unknown reason.
Error Log
Project code on github
Here's the important part of your error log:
java.lang.IllegalStateException: Attempted to set registry name with existing registry name! New: fur:decrafting_table Old: fur:decrafting_table
at net.minecraftforge.registries.IForgeRegistryEntry$Impl.setRegistryName(IForgeRegistryEntry.java:71)
at net.minecraftforge.registries.IForgeRegistryEntry$Impl.setRegistryName(IForgeRegistryEntry.java:79)
at com.furnacelztmod.blocks.BlockBase.<init>(BlockBase.java:23)
The problem is here:
public BlockBase(String name, Material material) {
super(material);
setUnlocalizedName(name);
setRegistryName(name);
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
BlockInit.BLOCKS.add(this);
Block iter=this;
iter.setRegistryName(iter.getRegistryName()); // line 23
ItemInit.ITEMS.add(new ItemBlock(iter));
}
Specifically, you shouldn't be doing iter.setRegistryName(iter.getRegistryName());. Forge doesn't let you do that, and even if it did, it would be a no-op, just setting the registry name to what it already was. I suspect you actually meant to set the registry name on the ItemBlock there, which you should be able to do by replacing the last three lines of that constructor with this:
ItemBlock iter=new ItemBlock(this);
iter.setRegistryName(this.getRegistryName());
ItemInit.ITEMS.add(iter);

How run cucumber using jar?

I have a project with cucumber and maven.
I can run and build my project successfully from Intellij IDEA.
And I can run project from the command line using:
mvn clean test -Dcucumber.options="src/test/resources/features --tags #TEST2"
Now I need to this project from the command line in another machine that does not have IDEA or cucumber installed. I have an idea that I need to create a jar-file and run exactly it from command line.
CucumberTest.java itself:
#RunWith(Cucumber.class)
#CucumberOptions(
monochrome = true,
glue = {"ru.ab.cd.stepDefs", "ru.abcd.tag.stepdefs"},
features = {"src/test/resources/features/"},
tags = {"#TEST1"},
plugin = {"pretty", "html:target/cucumber-html-report"}
)
public class CucumberTest {
}
TestRunner.java, that runs CucumberTest.java. I made this class specifically for being able to run from the command line. I wanted to pass the value for arguments from the command line. But I still don't understand what values should be passed and try to find out by passing
testArguments.
public class TestRunner{
public static void main(String[] args) throws Throwable {
String[] testArguments = {"/BitBucketProjects/abc/src/test/resources/features/smoke/TEST2.feature"};
cucumber.api.cli.Main.main(testArguments);
}
}
Result when I run TestRunner.java. The test itself did not start. All steps are defined, if I run the same test through the CucumberTest.java, everything is successful.
UUUUUUU
1 Scenarios (1 undefined)
7 Steps (7 undefined)
0m0,014s
You can implement missing steps with the snippets below:
#Допустим("^пользователь переходит на страницу авторизации$")
public void пользователь_переходит_на_страницу_авторизации() {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
#Допустим("^пользователь находится на странице \"([^\"]*)\"$")
public void пользователь_находится_на_странице(String arg1) {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
#Допустим("^пользователь загружает тестовые данные из json-файла$")
public void пользователь_загружает_тестовые_данные_из_json_файла() {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
#Допустим("^пользователь авторизуется с ролью \"([^\"]*)\"$")
public void пользователь_авторизуется_с_ролью(String arg1) {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
#Допустим("^ПРОВЕРКА\\. Ссылка \"([^\"]*)\" отображается на текущей странице$")
public void проверка_Ссылка_отображается_на_текущей_странице(String arg1) {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
#Допустим("^ПРОВЕРКА\\. Таблица \"([^\"]*)\" отображается на текущей странице$")
public void проверка_Таблица_отображается_на_текущей_странице(String arg1) {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
Process finished with exit code 0
Help!
What parameters should I pass to A in order for the test to run?
I need to use tags as parameters. How to do it?
The error said that cucumber does not see classes with step definition. Changed the class and the error disappeared
public class RunnerTest {
private static String[] defaultOptions = {
"--glue", "ru.ab.cd.stepDefs",
"--glue", "ru.abcd.tag.stepdefs",
"--tags", "#TEST2",
"src/test/resources/features/"
};
public static void main(String[] args) throws Throwable {
Stream<String> cucumberOptions = Stream.concat(Stream.of(defaultOptions), Stream.of(args));
cucumber.api.cli.Main.main(cucumberOptions.toArray(String[]::new));
}
}
"--glue" - a package that contains classes with the implementation
of steps and hooks
"--tags" - a filter for running tests by tags. This line can be deleted and the value passed through the console: --tags #TEST2
"src/test/resources/features/" - the last line that has no prefix like "--keyword" - is the path to the folder with .feature files.
The framework will search for files in this and in all child folders.

Vaadin SuperDevMode recompilation fails sometimes, Widget is not rendered as it should and Java code for the Widget is not available

I am trying to set up the SuperDevMode on a Vaadin project.
I have basically 3 problems related to this feature.
I have the following widget (created using the "New Vaadin Widget" wizard, below the code for the client-side widget, connector, state and server-side component):
// Widget:
public class CountedTextFieldWidget extends Composite {
private TextBox textBox = new TextBox();
private Label countLabel = new Label("0");
private HorizontalPanel panel = new HorizontalPanel();
public static final String CLASSNAME = "countedtextfield";
public CountedTextFieldWidget() {
initWidget(panel);
setStylePrimaryName(CLASSNAME);
textBox.setStylePrimaryName(CLASSNAME + "-field");
countLabel.setStylePrimaryName(CLASSNAME + "-label");
setStylePrimaryName(CLASSNAME);
panel.add(textBox);
panel.add(countLabel);
}
public String getText() {
return textBox.getText();
}
public void setText(String text) {
textBox.setText(text);
}
public void setCount(int count) {
countLabel.setText("" + count);
}
public int getCount() {
return Integer.parseInt(countLabel.getText());
}
// HandlerRegistration can be used to remove the key up handler (listener)
// added with this method
public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
return textBox.addKeyUpHandler(handler);
}
}
/********************************************************/
// Connector:
#Connect(CountedTextField.class)
public class CountedTextFieldConnector extends AbstractComponentConnector {
public CountedTextFieldConnector() {
getWidget().addKeyUpHandler(new KeyUpHandler() {
#Override
public void onKeyUp(KeyUpEvent event) {
String text = getWidget().getText();
getWidget().setCount(text.length());
}
});
}
#Override
protected Widget createWidget() {
return GWT.create(CountedTextFieldWidget.class);
}
#Override
public CountedTextFieldWidget getWidget() {
return (CountedTextFieldWidget) super.getWidget();
}
#Override
public CountedTextFieldState getState() {
return (CountedTextFieldState) super.getState();
}
#Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
final String text = getState().text;
getWidget().setText(text);
getWidget().setCount(text.length());
}
}
/********************************************************/
// State
public class CountedTextFieldState extends com.vaadin.shared.ui.textfield.AbstractTextFieldState {
{
primaryStyleName = null;
}
}
/********************************************************/
// Server-side component:
public class CountedTextField extends com.vaadin.ui.TextField {
#Override
public String getValue() {
return getState().text;
}
public void setValue(String value) {
getState().text = value;
}
#Override
public CountedTextFieldState getState() {
return (CountedTextFieldState) super.getState();
}
}
This widget is rendered as following:
Now, I have followed the following guide on the Vaadin's wiki:
https://vaadin.com/wiki/-/wiki/Main/Using%20SuperDevMode
The CodeServer starts as expected:
The code server is ready.
Next, visit: http://localhost:9876/
But when I open the project and append ?superdevmode to the URL, get the Recompilation failed... message and there's are some errors in the browser's console:
So my first problem is related to this issue:
1) Why does recompilation fail sometimes? And what are those SEVERE: JSONP compile call failed and SEVERE: Timeout Excecution?
Then if I ... click to retry sometimes the superdevmode starts, but the custom widget is not rendered as in the previous screenshot I posted.
Instead, I get a standard Vaadin's v-textfield...
2) WTF... Why? Where is my custom component?
I noticed that I get the same issue also if I open localhost:9876, drag the Dev Mode On button to the bookmarks toolbar and then click on it while on localhost:8080/project. My custom widget is disappears and instead I get the Vaadin's v-textfield widget...
And about the Enable Source Map feature. On the wiki, they say:
To be able to debug Java code in Chrome, open the Chrome Inspector
(right click -> Inspect Element), click the settings icon in the lower
corner of the window and check "Scripts -> Enable source maps".
Refresh the page with the inspector open and you will see Java code
instead of JavaScript code in the scripts tab.
In my Chrome, I don't have a settings icon on the lower corner of the window, I clicked the gear icon on the right and went to General -> Sources and checked Enable JavaScript Source Map (There's no generic Enable source maps entry on my settings tab).
I can see the Java sources, but they are all sources for GWT and Vaadin's components:
So my third issue and related question:
3) How can I see my custom widget code also?
Thanks for the attention! Hope I was clear.
I also had a similar problem trying to use SuperDev Mode with Vaadin. I'm not quite sure why recompilation fails on occasion, but I suspect it envolves the same issue I had trying to send my Java source maps. The problem I had seemed to be a caching issue due to the fact that the code server creates a persistent cache directory in my /tmp folder. So I deleted every folder it created (they usually have "gwt" in the name somewhere) and relaunched the code server. I suggest also adding the -src <complete-path-to-project> argument in the code server configurations to specify the directory containing GWT source to be prepended to the classpath for compiling and possibly changing the log level to TRACE or DEBUG. Heres an example those arguments:
com.example.AppWidgetSet -src /home/workspace/widgetset/src/main/java
-logLevel TRACE
I should mention that the log levels are quite verbose, but can be quite useful. The log should also show the location of the cache folder.

ESelectionService not working on receiving a message

I am using Eclipse 4.2 Juno, Java 1.6. I have two parts in my application. One part is registering the SelectionChangedListener:
#Inject
private ESelectionService selectionService;
#PostConstruct
public void init() {
TreeViewer bsTreeViewer = new TreeViewer(tabFolder, SWT.BORDER);
/* some other stuff */
// Event declaration
bsTreeViewer.addSelectionChangedListener(new SelectionChangedListener() {
#Override
public void selectionChanged(SelectionChangedEvent event) {
if( selectionService != null ) {
selectionService.setSelection(((IStructuredSelection)event.getSelection()).getFirstElement());
}
}
});
}
This Listener is called correctly. The first selected Element is of the right type, too.
I another part I am setting up the receiving end:
#Inject
public void setBS(#Named(IServiceConstants.ACTIVE_SELECTION) #Optional BS bs) {
if (bs == null) {
/* implementation not shown */
} else {
/* implementation not shown */
}
}
However, nothing is received on this end of the pipe. What am I doing wrong or how could I debug this?
The code above looks fine, but try to check the following issues:
check if the receiver object is created - if not, it won't receive an event
check if the receiver object is created by eclipse framework (for example if it is element of application model such as part, handler it is for sure created by the framework) - if not, the framework (selection service) does not know about the receiver object and cannot notify it

Categories