Robot Frameworkを.NETアプリケーションのテストに使用する予定ですが、Robot FrameworkがC#オブジェクトをインスタンス化してテストに使用する方法を理解するのに苦労しています。Robot FrameworkでC#オブジェクトをインスタンス化する
私は一緒に遊んだC#アプリケーションは非常に単純です:
SystemUnderTest solution
|_ DataAccess project (uses Entity Framework to connect to database)
| |_ SchoolContext class
|
|_ Models project
|_ Student class
|
|_ SchoolGrades project (class library)
|_ SchoolRoll class
|_ AddStudent(Student) method
私はデータベースに保存されなければならない学生オブジェクトを渡し、ロボットフレームワークからAddStudent方法を実行したいんです。
私は、.NETアプリケーションを呼び出すためにPython for .NET (pythonnet)を使用してPythonでのテストライブラリを書いた:パイソンからこれを呼び出す
import clr
import sys
class SchoolGradesLibrary (object):
def __init__(self, application_path, connection_string):
self._application_path = application_path
sys.path.append(application_path)
# Need application directory on sys path before we can add references to the DLLs.
clr.AddReference("SchoolGrades")
clr.AddReference("DataAccess")
clr.AddReference("Models")
from SchoolGrades import SchoolRoll
from DataAccess import SchoolContext
from Models import Student
context = SchoolContext(connection_string)
self._schoolRoll = SchoolRoll(context)
def add_student(self, student):
self._schoolRoll.AddStudent(student)
は動作します:
from SchoolGradesLibrary import SchoolGradesLibrary
import clr
application_path = r"C:\...\SchoolGrades\bin\Debug"
connection_string = r"Data Source=...;Initial Catalog=...;Integrated Security=True"
schoolLib = SchoolGradesLibrary(application_path, connection_string)
# Have to wait to add reference until after initializing SchoolGradesLibrary,
# as that adds the application directory to sys path.
clr.AddReference("Models")
from Models import Student
student = Student()
student.StudentName = "Python Student"
schoolLib.add_student(student)
私のように失われたビットですRobot Frameworkから同じことをどうやって行うのかについて説明します。私はこれを実行すると
*** Variables ***
${APPLICATION_PATH} = C:\...\SchoolGrades\bin\Debug
${CONNECTION_STRING} = Data Source=...;Initial Catalog=...;Integrated Security=True
*** Settings ***
Library SchoolGradesLibrary ${APPLICATION_PATH} ${CONNECTION_STRING}
*** Test Cases ***
Add Student To Database
${student} = Student
${student.StudentName} = RF Student
Add Student ${student}
それはエラーメッセージで失敗します:No keyword with name 'Student' found.
にはどうすれば追加学生キーワードに渡すために、ロボットのフレームワークで学生オブジェクトを作成することができますこれは私がこれまで持っているものです?明らかにテストに間違いがありますか?
C#アプリケーションは.NET 4.5.1で、Pythonバージョンは3.5で、Robot Frameworkバージョンは3.0です。
ありがとうございました。ありがとうございました。 –