S4064172 / Assessor

0 stars 0 forks source link

Function naming (Assert Problem) #5

Open S4064172 opened 2 years ago

S4064172 commented 2 years ago

Just performing some test, we noticed that in same case the tool is not able to create the function with the correct name.

We have to investigate in order to understand the problem.

Tips:

System.out.println("{ASSESSOR}:ReviewProduct:checkOut"); assertThat(driver.findElement(By.cssSelector(".nomargin > strong")).getText(), is("Vintage courier bag")); driver.findElement(By.cssSelector(".entry-header-area")).click(); System.out.println("{ASSESSOR}backToMain");

public String getCSSSELECTOR_nomarginstrong() { return driver.findElement(By.cssSelector(".nomargin > strong")).getText(); }

S4064172 commented 2 years ago

Now the tool uses the correct name, but during the development, we understand the motivation:

the tool tries to create an own function for the assert command and so, if the tester doesn't follow this idea, and put other commands with the assert the tool tries to split the instruction and so is not able to use the correct name.

with the changes, we get 2 different results:

1) absolute wrong

Image

2) could be correct, because theoretically, the assert command should br put inside its own function:

Image

I think that the second point could be camo out if we add the wait before the asserts.

S4064172 commented 2 years ago

During the integration test, we noticed that in some cases the tool failed and it used the wrong function name.

If the body method is already defined, the tool doesn't create a new method and try to use the other one but in the test use the name of the new method:

(In the plugin) @Test public void errorNaming_1() { System.out.println("{ASSESSOR}:UserProfile:CheckCorrectUser"); driver.findElement(By.linkText("Password")).click(); assertThat(driver.findElement(By.cssSelector(".widget-user-username")).getText(), is("Pippo")); System.out.println("{ASSESSOR}backToMain");

System.out.println("{ASSESSOR}:UserProfile:checkCorrectUser");
assertThat(driver.findElement(By.cssSelector(".widget-user-username")).getText(), is("Pluto (pluto)"));
System.out.println("{ASSESSOR}backToMain");

}

(in the PO) public void CheckCorrectUser() { By elem = By.linkText("Password"); MyUtils.WaitForElementLoaded(driver, elem); driver.findElement(By.linkText("Password")).click(); }

(in the Test) UserProfile _UserProfile = new UserProfile(driver, js, vars); _UserProfile.CheckCorrectUser(); assertThat(_UserProfile.CheckCorrectUser_1(), is("Pippo")); assertThat(_UserProfile.checkCorrectUser_1(), is("Pluto (pluto)"));

we fixed it