Skip to content

Latest commit

 

History

History
70 lines (57 loc) · 4.47 KB

tutorials-bughunt-java.md

File metadata and controls

70 lines (57 loc) · 4.47 KB

What is this?

We prepared for you a few manually introduced bugs in order to learn how to use Rookout.
The first two will make sure you understand how to create and analyze our default rule - Dump Frame.
The third bug will introduce a new rule type - Log. You will be walked through the process of editing the rule in order to add custom elements to it.

For more information about Rule Scripting refer to our reference

Bug scenarios

Level: Beginner

  • The bug: Clear Completed button does not work. When clicked - completed todos are not cleared.

    • Reproduce: Add a few todos, check one or more as completed using the checkbox on the left of the task and click the Clear completed button on the bottom right corner.
    • Debug:
      1. Load the app's code from github / local - as explained in here
      2. In the Rookout app, open the file src/main/java/com/rookout/tutorial/TodoController.java
        TodoController.java
      3. Add a dumpframe rule on the return of the clearCompleted function by clicking left to the line numbering (just like you would have created a breakpoint on an IDE)
        Clear Completed
      4. Try clicking on Clear completed again to see the message that pops in the Rookout app
      5. We can now see the whole stacktrace leading to this point and the local variables:
        Clear Completed
      6. Notice how we created a new variable todoStore instead of overriding todos
      7. Now we know what the bug is!

Level: Beginner

  • The bug: Special characters (<,>,;,`,&,/,\) are not being accepted as part of the title when Adding or Updating a Todo.
    • Reproduce: Add a todo with special characters. All of these characters should disappear.
    • Debug:
      1. In the Rookout app, open the file src/main/java/com/rookout/tutorial/TodoController.java
      2. In the addTodo function you will we see that the todo title is being filtered by replaceAll with a regex - Let's add a Dump Frame to the line after it newTodoRecord
      3. Try to add a todo with some special characters (e.g: do <> this)
      4. We can clearly see both newTodoRecord.title and todoTitle - which is the cleaned title. newTodoRecord

Level: Intermediate

  • The bug: Duplicate Todo adds an invalid todo instead of an exact copy of an existing one.
    • Reproduce: Add a task and when hovering on the text, on the right side you have the & symbol. Click on it to duplicate the task.

    • Debug:

      1. In the Rookout app, open the file src/main/java/com/rookout/tutorial/TodoController.java
      2. Using the Rules pane on the right, select the Rule Type "Log"
      3. Add the rule in the duplicateTodo function on the line with todos.add(newTodoRecord);
      4. Before triggering the rule, let's edit it so it returns what we want
      5. In the Rules pane on the right, click the Edit Rule (pen) icon next to the rule you just added. It will open up the Rule configuration as a JSON file
      6. On line 37 in the paths object let's add a property "store.rookout.locals.dup": "frame.newTodoRecord"
      7. On line 51 we have processing.operations object, let's add a new operation in the array : name: send_rookout - means we are sending the information to the rookout web application path: store.rookout.locals.dup - we tell the rule what information to send
      {
          "name": "send_rookout",
          "path": "store.rookout.locals.dup"
      }
      
      1. Click the save button on the upper pane.
      2. Add and duplicate a todo in order to see the output, now we can see what is being given to the object and match if we have an error in the function (parameters missing or in bad order). Invalid Duplicate Todo Record

Next steps

Head over to our reference to understand all the Rookout components.
See our installation guides for platform-specific installation examples.