This commit is contained in:
Lukáš Kaňka 2023-08-22 20:28:19 +02:00
commit 14d46cad1c
2236 changed files with 74214 additions and 0 deletions

View File

@ -0,0 +1,65 @@
**Nainstalovat do PC:**
.NET 7.0 nebo 6.0 s dlouhou podporou
Visual Studio Code
nebo
Visual Studio 2022 - pouze WIN a MacOS
**Potřebná rozšíření ve VS Code:**
.NET Extension Pack
C#
Nuget Package Manager
**Postup vs code:**
Založení nového projektu ve Visual Studio Code:
dotnet new mstest -n MyTestProject
**Stažení Selenia** (stahne potřebý základ): v terminálu musíme do složky projektu co vytvořila dotnet new mstest
dotnet add package Selenium.WebDriver
**Test se spustí:**
dotnet test
nebo za pomocí
dotnet watch který sám automaticky sleduje změny v kódu a je schopný spustit testy
Tento návod funguje jak pod Linux (odzkoušené v distribucích EndeavorOS, Ubuntu 22.04), MacOS, Windows 11.
Z důvodu kompaktibility jseou je na GitHub pouze samotný kód testu. Ostatní soubory a složky se vytvoří po založení projektu.
Složka TestResults také není součásti verze GitHub.
**Hints:**
klik na tlačítko
IWebElement tlačítko<nastavení proměnné> = driver.FindElement(By.Id("xPath tlačítka"));
tlačítko.Click();
expectedTitle = "O mně - Lukáš bloguje";
actualTitle = driver.Title;
Assert.AreEqual(expectedTitle, actualTitle, "Title does not match");

View File

@ -0,0 +1,104 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace MyTestProject;
[TestClass]
public class UnitTest1
{
String test_url = "https://lukan.cz/";
String itemName = "Lukáš Bloguje";
[TestMethod]
public void TestMethod1()
{
IWebDriver driver;
// Local Selenium WebDriver
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl(test_url);
driver.Manage().Window.Maximize();
// Kontrola titulku
string expectedTitle = "Lukáš bloguje - Blog o všem možném i nemožném";
string actualTitle = driver.Title;
Assert.AreEqual(expectedTitle, actualTitle, "Title does not match");
// Clikne na tlačítko
IWebElement Button_O_mne = driver.FindElement(By.Id("menu-item-79"));
Button_O_mne.Click();
// Kontrola titulku
expectedTitle = "O mně - Lukáš bloguje";
actualTitle = driver.Title;
Assert.AreEqual(expectedTitle, actualTitle, "Title does not match");
// Vrátí žpět na hlavní stranu
IWebElement Button_Hlavni_strana = driver.FindElement(By.Id("menu-item-75"));
Button_Hlavni_strana.Click();
// Počká tři sekundy na další akci
Thread.Sleep(3000);
Console.Write("Dotestováno");
// zavře prohlížeč
driver.Quit();
}
}

32
MSTest_Win/.github/__workflows/zive.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: zive mstest
on:
push:
branches: [main]
env:
MSTEST_VERSION: 2.2.10
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore MSTest_Win/zive/zive.csproj
- name: Build solution
run: dotnet build --configuration Release MSTest_Win/zive/zive.csproj
- name: Test with MSTest
run: dotnet test --configuration Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover MSTest_Win/zive/zive.csproj
env:
MSTEST_EXE: ./tools/mstest.exe

2
MSTest_Win/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,2 @@
{
}

1
MSTest_Win/zive/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/TestResults/

View File

@ -0,0 +1 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;

2
MSTest_Win/zive/bash.bat Normal file
View File

@ -0,0 +1,2 @@
@echo off
dotnet test --logger:"html;LogFilePath=testresults.html;"

View File

@ -0,0 +1,173 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions</name>
</assembly>
<members>
<member name="T:Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute">
<summary>
Used to specify deployment item (file or directory) for per-test deployment.
Can be specified on test class or test method.
Can have multiple instances of the attribute to specify more than one item.
The item path can be absolute or relative, if relative, it is relative to RunConfig.RelativePathRoot.
</summary>
<remarks>
If specified on a test class, the class needs to contain at least one test method. This means that the
attribute cannot be combined with a test class that would contain only a AssemblyInitialize or ClassInitialize
method.
</remarks>
<example>
[DeploymentItem("file1.xml")]
[DeploymentItem("file2.xml", "DataFiles")]
[DeploymentItem("bin\Debug")].
</example>
</member>
<member name="M:Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.#ctor(System.String)">
<summary>
Initializes a new instance of the <see cref="T:Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute"/> class.
</summary>
<param name="path">The file or directory to deploy. The path is relative to the build output directory. The item will be copied to the same directory as the deployed test assemblies.</param>
</member>
<member name="M:Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.#ctor(System.String,System.String)">
<summary>
Initializes a new instance of the <see cref="T:Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute"/> class.
</summary>
<param name="path">The relative or absolute path to the file or directory to deploy. The path is relative to the build output directory. The item will be copied to the same directory as the deployed test assemblies.</param>
<param name="outputDirectory">The path of the directory to which the items are to be copied. It can be either absolute or relative to the deployment directory. All files and directories identified by <paramref name="path"/> will be copied to this directory.</param>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.Path">
<summary>
Gets the path of the source file or folder to be copied.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.OutputDirectory">
<summary>
Gets the path of the directory to which the item is copied.
</summary>
</member>
<member name="T:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext">
<summary>
Used to store information that is provided to unit tests.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Properties">
<summary>
Gets test properties for a test.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.CancellationTokenSource">
<summary>
Gets or sets the cancellation token source. This token source is canceled when test times out. Also when explicitly canceled the test will be aborted.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory">
<summary>
Gets base directory for the test run, under which deployed files and result files are stored.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.DeploymentDirectory">
<summary>
Gets directory for files deployed for the test run. Typically a subdirectory of <see cref="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory"/>.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ResultsDirectory">
<summary>
Gets base directory for results from the test run. Typically a subdirectory of <see cref="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory"/>.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunResultsDirectory">
<summary>
Gets directory for test run result files. Typically a subdirectory of <see cref="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ResultsDirectory"/>.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestResultsDirectory">
<summary>
Gets directory for test result files.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestDir">
<summary>
Gets base directory for the test run, under which deployed files and result files are stored.
Same as <see cref="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory"/>. Use that property instead.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestDeploymentDir">
<summary>
Gets directory for files deployed for the test run. Typically a subdirectory of <see cref="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory"/>.
Same as <see cref="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.DeploymentDirectory"/>. Use that property instead.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestLogsDir">
<summary>
Gets directory for test run result files. Typically a subdirectory of <see cref="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ResultsDirectory"/>.
Same as <see cref="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunResultsDirectory"/>. Use that property for test run result files, or
<see cref="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestResultsDirectory"/> for test-specific result files instead.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.FullyQualifiedTestClassName">
<summary>
Gets the Fully-qualified name of the class containing the test method currently being executed.
</summary>
<remarks>
This property can be useful in attributes derived from ExpectedExceptionBaseAttribute.
Those attributes have access to the test context, and provide messages that are included
in the test results. Users can benefit from messages that include the fully-qualified
class name in addition to the name of the test method currently being executed.
</remarks>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ManagedType">
<summary>
Gets the fully specified type name metadata format.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ManagedMethod">
<summary>
Gets the fully specified method name metadata format.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestName">
<summary>
Gets the name of the test method currently being executed.
</summary>
</member>
<member name="P:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.CurrentTestOutcome">
<summary>
Gets the current test outcome.
</summary>
</member>
<member name="M:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.AddResultFile(System.String)">
<summary>
Adds a file name to the list in TestResult.ResultFileNames.
</summary>
<param name="fileName">
The file Name.
</param>
</member>
<member name="M:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Write(System.String)">
<summary>
Used to write trace messages while the test is running.
</summary>
<param name="message">formatted message string.</param>
</member>
<member name="M:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Write(System.String,System.Object[])">
<summary>
Used to write trace messages while the test is running.
</summary>
<param name="format">format string.</param>
<param name="args">the arguments.</param>
</member>
<member name="M:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.WriteLine(System.String)">
<summary>
Used to write trace messages while the test is running.
</summary>
<param name="message">formatted message string.</param>
</member>
<member name="M:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.WriteLine(System.String,System.Object[])">
<summary>
Used to write trace messages while the test is running.
</summary>
<param name="format">format string.</param>
<param name="args">the arguments.</param>
</member>
</members>
</doc>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More