Środowisko pracy Test
Wprowadzenie
Środowisko pracy Test nie jest tak naprawdę programem do modelowania, ale zawiera zestaw skryptów środowiska Python do wykonywania różnych testów na głównych komponentach programu FreeCAD w celu usuwania problemów. Zobacz także stronę debugowanie.
Testy można uruchamiać z wiersza poleceń, używając opcji -t
lub --run-test
.
Przeprowadzenie wszystkich testów:
freecad --run-test 0
Przeprowadzenie tylko niektórych testów jednostkowych, np:
freecad -t TestDraft
Jeśli test nie wymaga GUI, można go także wykonać w trybie konsoli, ustawiając dodatkowo opcję -c
lub --console
. Zwykle powoduje to znacznie szybszy czas uruchamiania, ponieważ GUI nie jest ładowane. Na przykład:
freecad -c -t TestPartDesignApp
Menu Narzędzia test
W każdym katalogu najwyższego poziomu w programie FreeCAD powinien znajdować się plik z testami, które można uruchomić dla danego programu lub modułu. Plik ten zwykle zaczyna się od słowa Test
.
Aby uruchomić test z poziomu programu FreeCAD, należy przejść do środowiska Test Workbench, następnie Test commands → TestToolsGui → Self test → Select test name, a następnie wpisać nazwę pliku Python z testami. Na przykład dla środowiska pracy Rysunek Roboczy będzie to TestDraft, po czym należy nacisnąć przycisk Start.
Funkcje testujące
To jest lista aplikacji testowych od wersji 0.15 git 4207:
TestAPP.All
Dodanie funkcji testowania
BaseTests
Dodanie funkcji testowania
UnitTests
Dodanie funkcji testowania
Document
Dodanie funkcji testowania
UnicodeTests
Dodanie funkcji testowania
MeshTestsApp
Dodanie funkcji testowania
TestDraft
Dodanie funkcji testowania
TestSketcherApp
Dodanie funkcji testowania
TestPartApp
Dodanie funkcji testowania
TestPartDesignApp
Add test function
TestPathApp
Path workbench test cases:
- depthTestCases:
- PathTestUtils:
- TestDressupDogbone: Test functionality of Dogbone dressup.
- TestHoldingTags: Test functionality of Holding Tags dressup.
- TestPathAdaptive: Test selection capability of Adaptive operation.
- TestPathCore: Test core functionality of Path workbench.
- TestPathDeburr: Test general functionality of Deburr operation.
- TestPathGeom: Test various functions available in the PathGeom module.
- TestPathHelix: Test general functionality of Helix operation.
- TestPathLog: Test various functions available in the PathLog debugging and feedback module.
- TestPathOpTools:
- TestPathPreferences: Test various functions available in the PathPreferences module.
- TestPathPropertyBag:
- TestPathSetupSheet:
- TestPathStock:
- TestPathThreadMilling:
- TestPathTool:
- TestPathToolBit:
- TestPathToolController:
- TestPathTooltable:
- TestPathUtil: Test various functions available in the PathUtil module.
- TestPathVcarve: Test general functionality of Vcarve operation.
- TestPathVoronoi:
Workbench
Add test function
Menu
Add test function
Menu.MenuDeleteCases
Add test function
Menu.MenuCreateCases
Add test function
Scripting
See also: FreeCAD Scripting Basics.
Get a list of all top-level test modules
FreeCAD.__unit_test__
Note that the test modules returned here depend on whether a GUI available or not. I.e. when executed in console mode, various tests ending in "Gui" are missing.
Run specific tests
There are various ways of running tests using Python's unittest library. FreeCAD's test framework removes some of the boiler plate for the most common cases.
Run all tests defined in a Python module:
import Test, TestFemApp
Test.runTestsFromModule(TestFemApp)
Run all tests defined in a Python class:
import Test, femtest.app.test_solver_calculix
Test.runTestsFromClass(femtest.app.test_solver_calculix.TestSolverCalculix)
Example 1
Within the Python Console of FreeCAD, the following code format may be used to run built-in tests. Replace the red "TestFem" text in the code below with the desired module test name.
- For example, use "TestPathApp" to run all unit tests for the Path workbench unit test framework.
- Submodules are available using dot notation, like "TestPathApp.TestPathAdaptive" to only run the Adaptive unit tests within the greater Path workbench test framework.
- Multiple test modules or submodules may be combined by adding another `suite.addTest(...)` method call just like the one in the code below, but with a different module or submodule reference.
- Output for the code below will be in the Report View panel within the FreeCAD GUI.
- Code source is copied from post by FreeCAD forum user, sgrogan, in the unit tests per python topic, with credit there given to forum user, wmayer.
import unittest
suite = unittest.TestSuite()
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestFem"))
r = unittest.TextTestRunner()
r.run(suite)
Additional Resources
Forum Topics
- Jak zacząć
- Instalacja: Pobieranie programu, Windows, Linux, Mac, Dodatkowych komponentów, Docker, AppImage, Ubuntu Snap
- Podstawy: Informacje na temat FreeCAD, Interfejs użytkownika, Profil nawigacji myszką, Metody wyboru, Nazwa obiektu, Edytor ustawień, Środowiska pracy, Struktura dokumentu, Właściwości, Pomóż w rozwoju FreeCAD, Dotacje
- Pomoc: Poradniki, Wideo poradniki
- Środowiska pracy: Strona Startowa, Złożenie, BIM, CAM, Rysunek Roboczy, MES, Inspekcja, Siatka, OpenSCAD, Część, Projekt Części, Punkty, Inżynieria Wsteczna, Robot, Szkicownik, Arkusz Kalkulacyjny, Powierzchnia 3D, Rysunek Techniczny, Test Framework