0% found this document useful (0 votes)
11 views3 pages

Program 38

The document contains Java test code for a Spring Boot frontend application, utilizing both TestRestTemplate and Selenium WebDriver for testing. It includes tests for the index and about pages, checking for HTTP status and page titles. Additionally, it specifies dependencies for Spring Boot testing and Selenium in the project configuration.

Uploaded by

v6jnhhy8d8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Program 38

The document contains Java test code for a Spring Boot frontend application, utilizing both TestRestTemplate and Selenium WebDriver for testing. It includes tests for the index and about pages, checking for HTTP status and page titles. Additionally, it specifies dependencies for Spring Boot testing and Selenium in the project configuration.

Uploaded by

v6jnhhy8d8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program-38

@RunWith([Link])
@SpringBootTest
public class FrontendApplicationTest {
@Autowired
private TestRestTemplate restTemplate;

@Test
public void testIndexPage() {
ResponseEntity<String> response = [Link]("/", [Link]);
assertEquals([Link], [Link]());
assertTrue([Link]().contains("Welcome to the Frontend Application"));
}

@Test
public void testAboutPage() {
ResponseEntity<String> response = [Link]("/about", [Link]);
assertEquals([Link], [Link]());
assertTrue([Link]().contains("About Us"));
}
}
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
@RunWith([Link])
@SpringBootTest
public class FrontendApplicationTest {
@Autowired
private WebApplicationContext context;

private WebDriver driver;

@Before
public void setup() {
driver = new ChromeDriver();
}

@Test
public void testIndexPage() {
[Link]("http:
assertTrue([Link]().contains("//localhost:8080/");
assertTrue([Link]().contains("Frontend Application"));
}

@Test
public void testAboutPage() {
[Link]("testAboutPage() {
[Link]("[Link]
assertTrue([Link]().contains("About Us"));
}

@After
public void tearDown() {
[Link]();
}
}
<dependency>
<groupId>[Link]</groupId>
<artifactId>selenium-java</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<scope>test</scope>
</dependency>
@RunWith([Link])
public class FrontendApplicationTest {
@Given("^I navigate to the index page$")
public void navigateToIndexPage() {
[Link]("http:
}

@Then("//localhost:8080/");
}

@Then("^I should see the title \"([^\"]*)\"$")


public void verifyTitle(String title) {
assertTrue([Link]().contains(title));
}
}

You might also like