vendredi 14 avril 2017

How to generate setter method value inside j unit testing?

Here, bbcSportsUrl has value of https://localhost:1000/index.html. When I debug my test, bbcSportsUrl has value until setter method however it doesn't get pass inside the junit method. It returns bbcSportsUrl as null thus it always gives me error.

It would be grateful if you could help me on this.

String bbcSportsUrl; 

public void setBbcSportsUrl(String bbcSportsUrl) {
   this.bbcSportsUrl = bbcSportsUrl; 
}

@Test
public void bbcWeatherTest() {
 HttpURLConnection conn; 
 URL url = new URL(bbcSportsUrl);
 connection =(HttpsURLConnection) url.openConnection();

assertEquals(HttpsURLConnection.HTTP_OK, conn.getResponseCode());
}

Aucun commentaire:

Enregistrer un commentaire