Empty xUnit Allure report

22 Views Asked by At

I have two simple tests that check the accessibility of a site by URL. Both tests work as intended.

IsUrlAvailableByHttp = Passed IsUrlAvailableByHttps = Failed

But when I create a report using "Allure" I get "0 test cases" in the Allure UI. Allure Report

I'm using next command to generate and open report:

allure generate
allure open

Here's code of my test.

public class WebProtocolTest
{
    private readonly PingHelper _pingHelper;

    [AllureBefore("Setup test context")]
    public WebProtocolTest()
    {
        _pingHelper = new PingHelper();
    }

    [Fact]
    [AllureDescription("Check app availability through http")]
    public void IsUrlAvailableByHttp()
    {
        string url = "http://localhost:5001/";

        bool isUrlAvailable = _pingHelper.IsUrlAvailable(url);

        Assert.True(isUrlAvailable);
    }

    [Fact]
    [AllureDescription("Check app availability through https")]
    public void IsUrlAvailableByHttps()
    {
        string url = "https://localhost:5001/";

        bool isUrlAvailable = _pingHelper.IsUrlAvailable(url);

        Assert.True(isUrlAvailable);
    }
}

public class PingHelper
{
    public bool IsUrlAvailable(string url)
    {
        bool urlAvailable = false;

        var request = (HttpWebRequest)HttpWebRequest.Create(url);
        request.AllowAutoRedirect = false;
        request.Method = "HEAD";
        
        try
        {
            var response = request.GetResponse();
            
            if(response != null)
            {
                urlAvailable = true;
            }
        }
        catch (WebException wex)
        {
            
        }

        return urlAvailable;
    }
}
1

There are 1 best solutions below

0
Oleksandr Kosovan On

Instead of using allure open and allure generate, you should use:

allure serve "D:\%PATH to your folder%\allure-results"