basic automation test for main pages.

pull/6/head
kayone 11 years ago
parent af5376f052
commit a5c4b45937

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading;
using FluentAssertions; using FluentAssertions;
using NLog; using NLog;
using NLog.Config; using NLog.Config;
@ -10,6 +11,8 @@ using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using OpenQA.Selenium; using OpenQA.Selenium;
using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI; using OpenQA.Selenium.Support.UI;
namespace NzbDrone.Automation.Test namespace NzbDrone.Automation.Test
@ -19,7 +22,7 @@ namespace NzbDrone.Automation.Test
public abstract class AutomationTest public abstract class AutomationTest
{ {
private NzbDroneRunner _runner; private NzbDroneRunner _runner;
protected FirefoxDriver driver; protected RemoteWebDriver driver;
public AutomationTest() public AutomationTest()
{ {
@ -31,7 +34,7 @@ namespace NzbDrone.Automation.Test
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget)); LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget));
} }
[SetUp] [TestFixtureSetUp]
public void SmokeTestSetup() public void SmokeTestSetup()
{ {
driver = new FirefoxDriver(); driver = new FirefoxDriver();
@ -57,22 +60,18 @@ namespace NzbDrone.Automation.Test
.Select(e => e.Text); .Select(e => e.Text);
} }
[TearDown] [TestFixtureTearDown]
public void SmokeTestTearDown() public void SmokeTestTearDown()
{ {
_runner.KillAll(); _runner.KillAll();
//driver.Quit(); driver.Quit();
} }
}
[TestFixture] [TearDown]
public class MyAutoTest : AutomationTest public void AutomationTearDown()
{
[Test]
public void Test1()
{ {
Thread.Sleep(2000);
GetPageErrors().Should().BeEmpty();
} }
} }
} }

@ -0,0 +1,46 @@
using FluentAssertions;
using NUnit.Framework;
namespace NzbDrone.Automation.Test
{
[TestFixture]
public class MainPagesTest : AutomationTest
{
[Test]
public void series_page()
{
driver.FindElementByLinkText("Series").Click();
driver.FindElementByClassName("iv-series-index-seriesindexlayout").Should().NotBeNull();
}
[Test]
public void calendar_page()
{
driver.FindElementByLinkText("Calendar").Click();
driver.FindElementByClassName("iv-calendar-calendarlayout").Should().NotBeNull();
}
[Test]
public void history_page()
{
driver.FindElementByLinkText("History").Click();
driver.FindElementByClassName("iv-history-historylayout").Should().NotBeNull();
}
[Test]
public void missing_page()
{
driver.FindElementByLinkText("Settings").Click();
}
[Test]
public void system_page()
{
driver.FindElementByLinkText("System").Click();
driver.FindElementByClassName("iv-system-systemlayout").Should().NotBeNull();
}
}
}

@ -61,6 +61,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="AutomationTestAttribute.cs" /> <Compile Include="AutomationTestAttribute.cs" />
<Compile Include="AutomationTest.cs" /> <Compile Include="AutomationTest.cs" />
<Compile Include="MainPagesTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -76,6 +77,11 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="IEDriverServer.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

@ -10,20 +10,28 @@ namespace NzbDrone.Integration.Test
[TestFixture] [TestFixture]
public class EpisodeIntegrationTests : IntegrationTest public class EpisodeIntegrationTests : IntegrationTest
{ {
private SeriesResource series;
[SetUp]
public void Setup()
{
series = GivenSeriesWithEpisodes();
}
private SeriesResource GivenSeriesWithEpisodes() private SeriesResource GivenSeriesWithEpisodes()
{ {
var series = Series.Lookup("archer").First(); var newSeries = Series.Lookup("archer").First();
series.QualityProfileId = 1; newSeries.QualityProfileId = 1;
series.Path = @"C:\Test\Archer".AsOsAgnostic(); newSeries.Path = @"C:\Test\Archer".AsOsAgnostic();
series = Series.Post(series); newSeries = Series.Post(newSeries);
while (true) while (true)
{ {
if (Episodes.GetEpisodesInSeries(series.Id).Count > 0) if (Episodes.GetEpisodesInSeries(newSeries.Id).Count > 0)
{ {
return series; return newSeries;
} }
Thread.Sleep(1000); Thread.Sleep(1000);
@ -33,28 +41,33 @@ namespace NzbDrone.Integration.Test
[Test] [Test]
public void should_be_able_to_get_all_episodes_in_series() public void should_be_able_to_get_all_episodes_in_series()
{ {
var series = GivenSeriesWithEpisodes();
Episodes.GetEpisodesInSeries(series.Id).Count.Should().BeGreaterThan(0); Episodes.GetEpisodesInSeries(series.Id).Count.Should().BeGreaterThan(0);
} }
[Test] [Test]
public void should_be_able_to_get_a_single_episode() public void should_be_able_to_get_a_single_episode()
{ {
var series = GivenSeriesWithEpisodes();
var episodes = Episodes.GetEpisodesInSeries(series.Id); var episodes = Episodes.GetEpisodesInSeries(series.Id);
Episodes.Get(episodes.First().Id).Should().NotBeNull(); Episodes.Get(episodes.First().Id).Should().NotBeNull();
} }
[Test] [Test]
public void should_be_able_to_set_monitor_status_via_api() public void should_be_able_to_set_monitor_status()
{ {
var series = GivenSeriesWithEpisodes();
var episodes = Episodes.GetEpisodesInSeries(series.Id); var episodes = Episodes.GetEpisodesInSeries(series.Id);
var updatedEpisode = episodes.First(); var updatedEpisode = episodes.First();
updatedEpisode.Monitored = false; updatedEpisode.Monitored = false;
Episodes.Put(updatedEpisode).Monitored.Should().BeFalse(); Episodes.Put(updatedEpisode).Monitored.Should().BeFalse();
} }
[TearDown]
public void TearDown()
{
Series.Delete(series.Id);
Thread.Sleep(2000);
}
} }
} }

@ -41,8 +41,8 @@ namespace NzbDrone.Integration.Test
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget)); LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget));
} }
//[TestFixtureSetUp] [TestFixtureSetUp]
[SetUp] //[SetUp]
public void SmokeTestSetup() public void SmokeTestSetup()
{ {
_runner = new NzbDroneRunner(); _runner = new NzbDroneRunner();
@ -65,8 +65,8 @@ namespace NzbDrone.Integration.Test
NamingConfig = new ClientBase<NamingConfigResource>(RestClient, _runner.ApiKey, "config/naming"); NamingConfig = new ClientBase<NamingConfigResource>(RestClient, _runner.ApiKey, "config/naming");
} }
//[TestFixtureTearDown] [TestFixtureTearDown]
[TearDown] //[TearDown]
public void SmokeTestTearDown() public void SmokeTestTearDown()
{ {
_runner.KillAll(); _runner.KillAll();

Loading…
Cancel
Save